Returns a usable keyword for a original keyword
@uses PhpReservedKeyword::instance()
@uses PhpReservedKeyword::is()
@param string $keyword the keyword
@param string $context the context
@return string
337297
public static function replacePhpReservedKeyword($keyword, $context = null)
    {
        if (PhpReservedKeyword::instance()->is($keyword)) {
            if ($context !== null) {
                $keywordKey = $keyword . '_' . $context;
                if (!array_key_exists($keywordKey, self::$replacedPhpReservedKeywords)) {
                    self::$replacedPhpReservedKeywords[$keywordKey] = 0;
                } else {
                    self::$replacedPhpReservedKeywords[$keywordKey]++;
                }
                return '_' . $keyword . (self::$replacedPhpReservedKeywords[$keywordKey] ? '_' . self::$replacedPhpReservedKeywords[$keywordKey] : '');
            } else {
                return '_' . $keyword;
            }
        } else {
            return $keyword;
        }
    }
1119933
public function context($context = null)
    {
        if (is_null($context)) {
            return $this->context;
        }

        $this->context = $context;

        return $this;
    }
387019
public function findByKeyword($keyword)
    {
        if ($keyword !== false) {
            $data = $this->getKeywordListFromCache();

            // 如果有完全匹配,直接返回
            if (isset($data[static::EXACT_MATCH][$keyword])) {
                return $this->findByIdFromCache($data[static::EXACT_MATCH][$keyword]);
            }

            // 判断是否有部分匹配
            foreach ($data[static::PARTIAL_MATCH] as $partialKeyword => $id) {
                if (strpos($keyword, (string) $partialKeyword) !== false) {
                    return $this->findByIdFromCache($id);
                }
            }
        }

        return '';
    }
117502
public function getContext( $key = null, $default = null ) {
		if ( $key === null ) {
			return $this->context;
		}

		return Arr::get( $this->context, $key, $default );
	}
1161970
private function findSynonym(KeywordInterface $keyword)
    {
        return $this->keywordRepository->findByKeyword($keyword->getKeyword(), $keyword->getLocale());
    }
127766
public function parseKeyword($string)
    {
        $matches = $this->parseKeywordText($string);
        return $this->parseKeywordToText($matches['keywords'], $matches['alias']);
    }
328358
public function get_keyword($key = 0)
	{
		$keywords = $this->get_keywords();
		if (isset($keywords[$key]))
		{
			return $keywords[$key];
		}

		return null;
	}
909670
public function keyword($keyword)
    {
        $this->andWhere([
            'or',
            ['and', '{{type}}=:typeMatch', '{{keyword}}=:keyword'], // 直接匹配关键字
            ['and', '{{type}}=:typeInclude', 'INSTR(:keyword, {{keyword}})>0'], // 包含关键字
            ['and', '{{type}}=:typeRegular', ':keyword REGEXP {{keyword}}'], // 正则匹配关键字
        ])
        ->addParams([
            ':keyword' => $keyword,
            ':typeMatch' => ReplyRuleKeyword::TYPE_MATCH,
            ':typeInclude' => ReplyRuleKeyword::TYPE_INCLUDE,
            ':typeRegular' => ReplyRuleKeyword::TYPE_REGULAR
        ]);
        return $this;
    }
1156332
public function getKeyword($language = null)
    {
        if (empty($language)) {
            $language = $this->mainLanguageCode;
        }

        if (!is_array($this->keywords) || !array_key_exists($language, $this->keywords)) {
            return null;
        }

        return $this->keywords[$language];
    }
179842
protected function isReservedPHPWord($word)
    {
        $word = strtolower($word);

        $keywords = [
            '__halt_compiler',
            'abstract',
            'and',
            'array',
            'as',
            'break',
            'callable',
            'case',
            'catch',
            'class',
            'clone',
            'const',
            'continue',
            'declare',
            'default',
            'die',
            'do',
            'echo',
            'else',
            'elseif',
            'empty',
            'enddeclare',
            'endfor',
            'endforeach',
            'endif',
            'endswitch',
            'endwhile',
            'eval',
            'exit',
            'extends',
            'final',
            'for',
            'foreach',
            'function',
            'global',
            'goto',
            'if',
            'implements',
            'include',
            'include_once',
            'instanceof',
            'insteadof',
            'interface',
            'isset',
            'list',
            'namespace',
            'new',
            'or',
            'print',
            'private',
            'protected',
            'public',
            'require',
            'require_once',
            'return',
            'static',
            'switch',
            'throw',
            'trait',
            'try',
            'unset',
            'use',
            'var',
            'while',
            'xor'
        ];

        $predefined_constants = [
            '__CLASS__',
            '__DIR__',
            '__FILE__',
            '__FUNCTION__',
            '__LINE__',
            '__METHOD__',
            '__NAMESPACE__',
            '__TRAIT__'
        ];

        return in_array($word, $keywords) || in_array($word, $predefined_constants);
    }
202279
public static function getKeywords()
    {
        static $keywords = null;

        if ($keywords === null) {
            $keywords = [];

            $keywordsStrings = [
                'T_ABSTRACT', 'T_ARRAY', 'T_AS', 'T_BREAK', 'T_CALLABLE', 'T_CASE',
                'T_CATCH', 'T_CLASS', 'T_CLONE', 'T_CONST', 'T_CONTINUE', 'T_DECLARE', 'T_DEFAULT', 'T_DO',
                'T_ECHO', 'T_ELSE', 'T_ELSEIF', 'T_EMPTY', 'T_ENDDECLARE', 'T_ENDFOR', 'T_ENDFOREACH',
                'T_ENDIF', 'T_ENDSWITCH', 'T_ENDWHILE', 'T_EVAL', 'T_EXIT', 'T_EXTENDS', 'T_FINAL',
                'T_FINALLY', 'T_FOR', 'T_FOREACH', 'T_FUNCTION', 'T_GLOBAL', 'T_GOTO', 'T_HALT_COMPILER',
                'T_IF', 'T_IMPLEMENTS', 'T_INCLUDE', 'T_INCLUDE_ONCE', 'T_INSTANCEOF', 'T_INSTEADOF',
                'T_INTERFACE', 'T_ISSET', 'T_LIST', 'T_LOGICAL_AND', 'T_LOGICAL_OR', 'T_LOGICAL_XOR',
                'T_NAMESPACE', 'T_NEW', 'T_PRINT', 'T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC', 'T_REQUIRE',
                'T_REQUIRE_ONCE', 'T_RETURN', 'T_STATIC', 'T_SWITCH', 'T_THROW', 'T_TRAIT', 'T_TRY',
                'T_UNSET', 'T_USE', 'T_VAR', 'T_WHILE', 'T_YIELD',
            ];

            foreach ($keywordsStrings as $keywordName) {
                if (defined($keywordName)) {
                    $keyword = constant($keywordName);
                    $keywords[$keyword] = $keyword;
                }
            }
        }

        return $keywords;
    }
520137
def get_existing_keyword(self, keyword):
        
        if self.existing_keywords is None:
            return {}
        if keyword is not None:
            return self.existing_keywords.get(keyword, {})
        else:
            return {}
105895
public function getKeyword($key) {
        if ($this->hasKeyword($key)) {
            return $this->_keywords[$key];
        }

        throw new MissingKeywordException(sprintf('Missing keyword %s', $key));
    }
833050
public function process($keyword){
        switch($keyword){
            case 'DATE_NOW':
                return strval(time());
            case 'DATE_Y4':
            case 'DATE_YEAR':
                return date('Y');
            case 'DATE_Y2':
                return date('y');
            case 'DATE_M':
            case 'DATE_MONTH':
                return date('m');
            case 'DATE_N':
                return date('n');
            case 'DATE_D':
            case 'DATE_DAY':
                return date('d');
            case 'DATE_J':
                return date('j');
            case 'DATE_H24':
            case 'DATE_HOUR':
                return date('H');
            case 'DATE_H12':
                return date('h');
            case 'DATE_I':
            case 'DATE_MINUTE':
                return date('i');
            case 'DATE_S':
            case 'DATE_SECOND':
                return date('s');
            case 'DATE_U':
            case 'DATE_MSEC':
                $t = microtime(true);
                return sprintf("%06d",($t - floor($t)) * 1000000);
        }
        return NULL;
    }
886939
protected function getKeywordAsArray($keywords) {
        $keywordWithoutOperator = preg_replace(explode('|', KeywordableTraitInterface::OPERATOR_SPLIT), ' ', $keywords);
        $keywordArray = explode(' ', $keywordWithoutOperator);

        return $keywordArray;
    }
973926
protected function _translate($string, $context = null)
    {
        if (!(($translator = $this->_getTranslator()) instanceof StringTranslatorInterface)) {
            return $string;
        }

        return $translator->translate($string, $context);
    }
566266
private static function removeKeyword($clause, $keyword)
    {
        $keyword .= ' ';
        if (stristr(substr($clause, 0, strlen($keyword)), $keyword) !== false) {
            return substr($clause, strlen($keyword));
        }

        return $clause;
    }