T_ELLIPSIS
T_ELLIPSIS = 1001
__construct(array $options = array())
Creates a Lexer.
array | $options | 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. |
startLexing(string $code, \PhpParser\ErrorHandler $errorHandler = null)
Initializes the lexer for lexing the provided source code.
This function does not throw if lexing errors occur. Instead, errors may be retrieved using the getErrors() method.
string | $code | The source code to lex |
\PhpParser\ErrorHandler | $errorHandler | Error handler to use for lexing errors. Defaults to ErrorHandler\Throwing |
getNextToken(mixed $value = null, mixed $startAttributes = null, mixed $endAttributes = null) : integer
Fetches the next token.
The available attributes are determined by the 'usedAttributes' option, which can be specified in the constructor. The following attributes are supported:
mixed | $value | Variable to store token content in |
mixed | $startAttributes | Variable to store start attributes in |
mixed | $endAttributes | Variable to store end attributes in |
Token id
getTokens() : array
Returns the token array for current code.
The token array is in the same format as provided by the token_get_all() function and does not discard tokens (i.e. whitespace and comments are included). The token position attributes are against this token array.
Array of tokens in token_get_all() format
handleErrors(\PhpParser\ErrorHandler $errorHandler)
\PhpParser\ErrorHandler | $errorHandler |
handleInvalidCharacterRange( $start, $end, $line, \PhpParser\ErrorHandler $errorHandler)
$start | ||
$end | ||
$line | ||
\PhpParser\ErrorHandler | $errorHandler |