PHP 클래스 PhpParser\Lexer

파일 보기 프로젝트 열기: nikic/php-parser 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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