Note: This documentation was auto-generated using this parser to help dogfood the API. It may be incomplete. Please contribute fixes to
tools/PrintApiDocumentation.php
and suggest API improvements.
TODO: add doc comment
public function getNodeKindName ( ) : string
Gets start position of Node, not including leading comments and whitespace.
public function getStartPosition ( ) : int
Gets start position of Node, including leading comments and whitespace
public function getFullStartPosition ( ) : int
Gets parent of current node (returns null if has no parent)
public function getParent ( )
Gets first ancestor that is an instance of one of the provided classes. Returns null if there is no match.
public function getFirstAncestor ( ...$classNames )
Gets first child that is an instance of one of the provided classes. Returns null if there is no match.
public function getFirstChildNode ( ...$classNames )
Gets first descendant node that is an instance of one of the provided classes. Returns null if there is no match.
public function getFirstDescendantNode ( ...$classNames )
Gets root of the syntax tree (returns self if has no parents)
public function getRoot ( ) : Node
Gets generator containing all descendant Nodes and Tokens.
public function getDescendantNodesAndTokens ( callable $shouldDescendIntoChildrenFn = null )
Gets a generator containing all descendant Nodes.
public function getDescendantNodes ( callable $shouldDescendIntoChildrenFn = null )
Gets generator containing all descendant Tokens.
public function getDescendantTokens ( callable $shouldDescendIntoChildrenFn = null )
Gets generator containing all child Nodes and Tokens (direct descendants). Does not return null elements.
public function getChildNodesAndTokens ( ) : \Generator
Gets generator containing all child Nodes (direct descendants)
public function getChildNodes ( ) : \Generator
Gets generator containing all child Tokens (direct descendants)
public function getChildTokens ( )
Gets array of declared child names (cached). This is used as an optimization when iterating over nodes: For direct iteration PHP will create a properties hashtable on the object, thus doubling memory usage. We avoid this by iterating over just the names instead.
public function getChildNames ( )
Gets width of a Node (not including comment / whitespace trivia)
public function getWidth ( ) : int
Gets width of a Node (including comment / whitespace trivia)
public function getFullWidth ( ) : int
Gets string representing Node text (not including leading comment + whitespace trivia)
public function getText ( ) : string
Gets full text of Node (including leading comment + whitespace trivia)
public function getFullText ( ) : string
Gets string representing Node's leading comment and whitespace text.
public function getLeadingCommentAndWhitespaceText ( ) : string
TODO: add doc comment
public function jsonSerialize ( )
Get the end index of a Node.
public function getEndPosition ( )
TODO: add doc comment
public function getFileContents ( ) : string
TODO: add doc comment
public function getUri ( ) : string
TODO: add doc comment
public function getLastChild ( )
Searches descendants to find a Node at the given position.
public function getDescendantNodeAtPosition ( int $pos )
Gets leading PHP Doc Comment text corresponding to the current Node. Returns last doc comment in leading comment / whitespace trivia, and returns null if there is no preceding doc comment.
public function getDocCommentText ( )
TODO: add doc comment
public function __toString ( )
TODO: add doc comment
public function getImportTablesForCurrentScope ( )
Gets corresponding NamespaceDefinition for Node. Returns null if in global namespace.
public function getNamespaceDefinition ( )
TODO: add doc comment
public function getPreviousSibling ( )
TODO: add doc comment
public function __construct ( $kind, $fullStart, $start, $length )
TODO: add doc comment
public function getLeadingCommentsAndWhitespaceText ( string $document ) : string
TODO: add doc comment
public function getText ( string $document = null )
TODO: add doc comment
public function getFullText ( string & $document ) : string
TODO: add doc comment
public function getStartPosition ( )
TODO: add doc comment
public function getFullStartPosition ( )
TODO: add doc comment
public function getWidth ( )
TODO: add doc comment
public function getFullWidth ( )
TODO: add doc comment
public function getEndPosition ( )
TODO: add doc comment
public static function getTokenKindNameFromValue ( $kind )
TODO: add doc comment
public function jsonSerialize ( )
TODO: add doc comment
public function __construct ( )
Generates AST from source file contents. Returns an instance of SourceFileNode, which is always the top-most Node-type of the tree.
public function parseSourceFile ( string $fileContents, string $uri = null ) : SourceFileNode
TODO: add doc comment
public static function checkDiagnostics ( $node )
TODO: add doc comment
public static function getDiagnostics ( Node $n ) : array
Gets a Range from 0-indexed position into $text. Out of bounds positions are handled gracefully. Positions greater than the length of text length are resolved to the end of the text, and negative positions are resolved to the beginning.
public static function getRangeFromPosition ( $pos, $length, $text ) : Range
Gets 0-indexed LineCharacterPosition from 0-indexed position into $text. Out of bounds positions are handled gracefully. Positions greater than the length of text length are resolved to text length, and negative positions are resolved to 0. TODO consider throwing exception instead.
public static function getLineCharacterPositionFromPosition ( $pos, $text ) : LineCharacterPosition
TODO: add doc comment
public function __construct ( int $line, int $character )
TODO: add doc comment
public function __construct ( int $kind, int $fullStart )
TODO: add doc comment
public function jsonSerialize ( )
TODO: add doc comment
public function __construct ( Token $token )
TODO: add doc comment
public function jsonSerialize ( )
TODO: complete documentation - in addition to the helper methods on the Node base class, every Node object has properties specific to the Node type. Browse
src/Node/
to explore these properties.