PHP Класс PhpParser\Lexer

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$code
$dropTokens
$filePos
$line
$pos
$prevCloseTagHasNewline
$tokenMap
$tokens
$usedAttributes

Открытые методы

Метод Описание
__construct ( array $options = [] ) Creates a Lexer.
getNextToken ( mixed &$value = null, mixed &$startAttributes = null, mixed &$endAttributes = null ) : integer Fetches the next token.
getTokens ( ) : array Returns the token array for current code.
handleHaltCompiler ( ) : string Handles __halt_compiler() by returning the text after it.
startLexing ( string $code, phpparser\ErrorHandler $errorHandler = null ) Initializes the lexer for lexing the provided source code.

Защищенные методы

Метод Описание
createTokenMap ( ) : array Creates the token map.
handleErrors ( phpparser\ErrorHandler $errorHandler )
resetErrors ( )

Приватные методы

Метод Описание
errorMayHaveOccurred ( )
handleInvalidCharacterRange ( $start, $end, $line, phpparser\ErrorHandler $errorHandler )
isUnterminatedComment ( $token )

Описание методов

__construct() публичный Метод

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.

createTokenMap() защищенный Метод

The token map maps the PHP internal token identifiers to the identifiers used by the Parser. Additionally it maps T_OPEN_TAG_WITH_ECHO to T_ECHO and T_CLOSE_TAG to ';'.
protected createTokenMap ( ) : array
Результат array The token map

getNextToken() публичный Метод

The available attributes are determined by the 'usedAttributes' option, which can be specified in the constructor. The following attributes are supported: * 'comments' => Array of PhpParser\Comment or PhpParser\Comment\Doc instances, representing all comments that occurred between the previous non-discarded token and the current one. * 'startLine' => Line in which the node starts. * 'endLine' => Line in which the node ends. * 'startTokenPos' => Offset into the token array of the first token in the node. * 'endTokenPos' => Offset into the token array of the last token in the node. * 'startFilePos' => Offset into the code string of the first character that is part of the node. * 'endFilePos' => Offset into the code string of the last character that is part of the node.
public getNextToken ( mixed &$value = null, mixed &$startAttributes = null, mixed &$endAttributes = null ) : integer
$value mixed Variable to store token content in
$startAttributes mixed Variable to store start attributes in
$endAttributes mixed Variable to store end attributes in
Результат integer Token id

getTokens() публичный Метод

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.
public getTokens ( ) : array
Результат array Array of tokens in token_get_all() format

handleErrors() защищенный Метод

protected handleErrors ( phpparser\ErrorHandler $errorHandler )
$errorHandler phpparser\ErrorHandler

handleHaltCompiler() публичный Метод

Handles __halt_compiler() by returning the text after it.
public handleHaltCompiler ( ) : string
Результат string Remaining text

resetErrors() защищенный Метод

protected resetErrors ( )

startLexing() публичный Метод

This function does not throw if lexing errors occur. Instead, errors may be retrieved using the getErrors() method.
public startLexing ( string $code, phpparser\ErrorHandler $errorHandler = null )
$code string The source code to lex
$errorHandler phpparser\ErrorHandler Error handler to use for lexing errors. Defaults to ErrorHandler\Throwing

Описание свойств

$code защищенное свойство

protected $code

$dropTokens защищенное свойство

protected $dropTokens

$filePos защищенное свойство

protected $filePos

$line защищенное свойство

protected $line

$pos защищенное свойство

protected $pos

$prevCloseTagHasNewline защищенное свойство

protected $prevCloseTagHasNewline

$tokenMap защищенное свойство

protected $tokenMap

$tokens защищенное свойство

protected $tokens

$usedAttributes защищенное свойство

protected $usedAttributes