Copied!
Cloneable Instantiable
Extends PhpParser\ParserAbstract
Implements PhpParser\Parser
Constants
public PhpParser\ParserAbstract ::SYMBOL_NONE = -1
Methods
public PhpParser\ParserAbstract :: __construct ( PhpParser\Lexer $lexer , array $options = [ ] )
 

Creates a parser instance.

Options: Currently none.

public PhpParser\ParserAbstract :: parse ( string $code , ? PhpParser\ErrorHandler $errorHandler = NULL )
 

Parses PHP code into a node tree.

If a non-throwing error handler is used, the parser will continue parsing after an error
occurred and attempt to build a partial AST.

  • return Node\Stmt []| null Array of statements (or null non-throwing error handler is used and the parser was unable to recover from an error).
Properties
protected $action
protected $actionBase
protected $actionCheck
protected $actionDefault
protected $actionTableSize
protected $defaultAction
protected PhpParser\ParserAbstract :: $endAttributes
 
  • var array End attributes of last *shifted* token
protected PhpParser\ParserAbstract :: $endAttributeStack
 
  • var array [] End attribute stack
protected PhpParser\ParserAbstract :: $errorHandler
 
  • var ErrorHandler Error handler
protected PhpParser\ParserAbstract :: $errorState
 
  • var int Error state, used to avoid error floods
protected $errorSymbol
protected $goto
protected $gotoBase
protected $gotoCheck
protected $gotoDefault
protected $gotoTableSize
protected $invalidSymbol
protected PhpParser\ParserAbstract :: $lexer
 
  • var Lexer Lexer that is used when parsing
protected PhpParser\ParserAbstract :: $lookaheadStartAttributes
 
  • var array Start attributes of last *read* token
protected $numNonLeafStates
protected PhpParser\ParserAbstract :: $productions
 
  • var array Names of the production rules (only necessary for debugging)
protected PhpParser\ParserAbstract :: $reduceCallbacks
 
  • var callable [] Semantic action callbacks
protected $ruleToLength
protected $ruleToNonTerminal
protected PhpParser\ParserAbstract :: $semStack
 
  • var array Semantic value stack (contains values of tokens and semantic action results)
protected PhpParser\ParserAbstract :: $semValue
 
  • var mixed Temporary value containing the result of last semantic action (reduction)
protected PhpParser\ParserAbstract :: $startAttributeStack
 
  • var array [] Start attribute stack
protected $symbolToName
protected $tokenToSymbol
protected $tokenToSymbolMapSize
protected $unexpectedTokenRule
protected $YY2TBLSTATE
Methods
protected PhpParser\ParserAbstract :: checkClass ( PhpParser\Node\Stmt\Class_ $node , $namePos )
protected PhpParser\ParserAbstract :: checkClassConst ( PhpParser\Node\Stmt\ClassConst $node , $modifierPos )
protected PhpParser\ParserAbstract :: checkClassMethod ( PhpParser\Node\Stmt\ClassMethod $node , $modifierPos )
protected PhpParser\ParserAbstract :: checkInterface ( PhpParser\Node\Stmt\Interface_ $node , $namePos )
protected PhpParser\ParserAbstract :: checkModifier ( $a , $b , $modifierPos )
protected PhpParser\ParserAbstract :: checkNamespace ( PhpParser\Node\Stmt\Namespace_ $node )
protected PhpParser\ParserAbstract :: checkParam ( PhpParser\Node\Param $node )
protected PhpParser\ParserAbstract :: checkProperty ( PhpParser\Node\Stmt\Property $node , $modifierPos )
protected PhpParser\ParserAbstract :: checkTryCatch ( PhpParser\Node\Stmt\TryCatch $node )
protected PhpParser\ParserAbstract :: checkUseUse ( PhpParser\Node\Stmt\UseUse $node , $namePos )
protected PhpParser\ParserAbstract :: createCommentNopAttributes ( array $comments )
 

Create attributes for a zero-length common-capturing nop.

  • return array
protected PhpParser\ParserAbstract :: doParse ()
protected PhpParser\ParserAbstract :: emitError ( PhpParser\Error $error )
protected PhpParser\ParserAbstract :: fixupPhp5StaticPropCall ( $prop , array $args , array $attributes ) : PhpParser\Node\Expr\StaticCall
 

Fix up parsing of static property calls in PHP 5.

In PHP 5 A::$b[c][d] and A::$b[c][d]() have very different interpretation. The former is
interpreted as (A::$b)[c][d], while the latter is the same as A::{$b[c][d]}(). We parse the
latter as the former initially and this method fixes the AST into the correct form when we
encounter the "()".

  • return Expr\StaticCall
protected PhpParser\ParserAbstract :: fixupStartAttributes ( PhpParser\Node $to , PhpParser\Node $from )
protected PhpParser\ParserAbstract :: getAttributesAt ( int $pos ) : array
 

Get combined start and end attributes at a stack location

  • return array Combined start and end attributes
protected PhpParser\ParserAbstract :: getErrorMessage ( int $symbol , int $state ) : string
 

Format error message including expected tokens.

  • return string Formatted error message
protected PhpParser\ParserAbstract :: getExpectedTokens ( int $state ) : array
 

Get limited number of expected tokens in given state.

  • return string [] Expected tokens. If too many, an empty array is returned.
protected PhpParser\ParserAbstract :: getFloatCastKind ( string $cast ) : int
protected PhpParser\ParserAbstract :: handleBuiltinTypes ( PhpParser\Node\Name $name )
protected PhpParser\ParserAbstract :: handleNamespaces ( array $stmts ) : array
 

Moves statements of semicolon-style namespaces into $ns->stmts and checks various error conditions.

  • return Node\Stmt []
protected initReduceCallbacks ()
protected PhpParser\ParserAbstract :: parseDocString ( string $startToken , $contents , string $endToken , array $attributes , array $endTokenAttributes , bool $parseUnicodeEscape )
protected PhpParser\ParserAbstract :: parseLNumber ( $str , $attributes , $allowInvalidOctal = false )
protected PhpParser\ParserAbstract :: parseNumString ( string $str , array $attributes )
 

Parse a T_NUM_STRING token into either an integer or string node.

  • return LNumber | String_ Integer or string node.
protected PhpParser\ParserAbstract :: stripIndentation ( string $string , int $indentLen , string $indentChar , bool $newlineAtStart , bool $newlineAtEnd , array $attributes )
Methods
private PhpParser\ParserAbstract :: fixupNamespaceAttributes ( PhpParser\Node\Stmt\Namespace_ $stmt )
private PhpParser\ParserAbstract :: getNamespacingStyle ( array $stmts )
 

Determine namespacing style (semicolon or brace)

  • return null | string One of "semicolon", "brace" or null (no namespaces)
© 2020 Bruce Wells
Search Namespaces \ Classes
Configuration Numbers (0-9.) only