Creates a Lexer.
public __construct ( array $options = [] ) | ||
$options | array | Options array. Currently only the 'usedAttributes' option is supported, which is an array of attributes to add to the AST nodes. Possible attributes are: 'comments', 'startLine', 'endLine', 'startTokenPos', 'endTokenPos', 'startFilePos', 'endFilePos'. The option defaults to the first three. For more info see getNextToken() docs. |
public function __construct(array $options = array()) { parent::__construct($options); $newKeywordsPerVersion = array(self::PHP_5_5 => array('finally' => Parser::T_FINALLY, 'yield' => Parser::T_YIELD), self::PHP_5_4 => array('callable' => Parser::T_CALLABLE, 'insteadof' => Parser::T_INSTEADOF, 'trait' => Parser::T_TRAIT, '__trait__' => Parser::T_TRAIT_C)); $this->newKeywords = array(); foreach ($newKeywordsPerVersion as $version => $newKeywords) { if (version_compare(PHP_VERSION, $version, '>=')) { break; } $this->newKeywords += $newKeywords; } if (version_compare(PHP_VERSION, self::PHP_5_6, '<')) { $this->tokenMap[self::T_ELLIPSIS] = Parser::T_ELLIPSIS; $this->tokenMap[self::T_POW] = Parser::T_POW; $this->tokenMap[self::T_POW_EQUAL] = Parser::T_POW_EQUAL; } }
public function __construct(array $options = array()) { parent::__construct($options); $newKeywordsPerVersion = array(); $this->newKeywords = array(); foreach ($newKeywordsPerVersion as $version => $newKeywords) { if (version_compare(PHP_VERSION, $version, '>=')) { break; } $this->newKeywords += $newKeywords; } if (version_compare(PHP_VERSION, self::PHP_7_0, '>=')) { return; } $this->tokenMap[self::T_COALESCE] = Tokens::T_COALESCE; $this->tokenMap[self::T_SPACESHIP] = Tokens::T_SPACESHIP; $this->tokenMap[self::T_YIELD_FROM] = Tokens::T_YIELD_FROM; if (version_compare(PHP_VERSION, self::PHP_5_6, '>=')) { return; } $this->tokenMap[self::T_ELLIPSIS] = Tokens::T_ELLIPSIS; $this->tokenMap[self::T_POW] = Tokens::T_POW; $this->tokenMap[self::T_POW_EQUAL] = Tokens::T_POW_EQUAL; }