- Location
- Position
- Node
Parameters
withPositionswithSource
Check and fix precence, by default using right
Parameters
result
Prepares an AST node
Parameters
kind(String | null) Defines the node type (if null, the kind must be passed at the function call)parserParser The parser instance (use for extracting locations)
Returns Function
The AST builder class
Parameters
withPositionswithSource
Properties
withPositionsBoolean Should locate any node (by default false)withSourceBoolean Should extract the node original code (by default false)
Check and fix precence, by default using right
Parameters
result
Prepares an AST node
Parameters
kind(String | null) Defines the node type (if null, the kind must be passed at the function call)parserParser The parser instance (use for extracting locations)
Returns Function
Extends Expression
Defines an array structure
Properties
itemsArray<Entry> List of array itemsshortFormboolean Indicate if the short array syntax is used, ex[]insteadarray()
Examples
// PHP code :
[1, 'foo' => 'bar', 3]
// AST structure :
{
"kind": "array",
"shortForm": true
"items": [{
"kind": "entry",
"key": null,
"value": {"kind": "number", "value": "1"}
}, {
"kind": "entry",
"key": {"kind": "string", "value": "foo", "isDoubleQuote": false},
"value": {"kind": "string", "value": "bar", "isDoubleQuote": false}
}, {
"kind": "entry",
"key": null,
"value": {"kind": "number", "value": "3"}
}]
}Extends Statement
Assigns a value to the specified target
Properties
leftExpressionrightExpressionoperatorString
Extends Operation
Binary operations
Properties
typeStringleftExpressionrightExpression
Extends Statement
A block statement, i.e., a sequence of statements surrounded by braces.
Properties
Extends Literal
Defines a boolean value (true/false)
Extends Node
A break statement
Properties
Extends Statement
Executes a call statement
Properties
argumentsArray<Arguments>
Extends Node
A switch case statement
Properties
test(Expression | null) if null, means that the default casebody(Block | null)
Extends Operation
Binary operations
Properties
typeStringwhatExpression
Extends Statement
Defines a catch statement
Properties
whatArray<Identifier>variableVariablebodyStatement
Extends Declaration
A class definition
Properties
extends(Identifier | null)implementsArray<Identifier>bodyArray<Declaration>isAnonymousbooleanisAbstractbooleanisFinalboolean
Extends Constant
Defines a class/interface/trait constant
Properties
Extends Statement
Defines a clone call
Properties
whatExpression
Extends Statement
Defines a closure
Properties
argumentsArray<Parameter>usesArray<Variable>typeIdentifierbyrefbooleannullablebooleanbody(Block | null)isStaticboolean
Extends Declaration
Defines a namespace constant
Properties
value(Node | null)
Extends Expression
A constant reference
Properties
Extends Node
A continue statement
Properties
Extends Statement
A declaration statement (function, class, interface...)
Properties
namestring
Generic flags parser
Parameters
flagsArray<Integer>
Returns void
Extends Block
The declare construct is used to set execution directives for a block of code
Properties
whatArray<Expression>modeString
The node is declared as a short tag syntax :
<?php
declare(ticks=1):
// some statements
enddeclare;Type: String
The node is declared bracket enclosed code :
<?php
declare(ticks=1) {
// some statements
}Type: String
The node is declared as a simple statement. In order to make things simpler children of the node are automatically collected until the next declare statement.
<?php
declare(ticks=1);
// some statements
declare(ticks=2);
// some statementsType: String
Extends Statement
Defines a do/while statement
Properties
testExpressionbodyStatement
Extends Node
A comment or documentation
Properties
Extends Sys
Defines system based call
Extends Sys
Defines an empty check call
Extends Literal
Defines an encapsed string (contains expressions)
Properties
typeString Defines the type of encapsed string (shell, heredoc, string)label(String | Null) The heredoc label, defined only when the type is heredoc
The node is a double quote string :
<?php
echo "hello $world";Type: String
The node is a shell execute string :
<?php
echo `ls -larth $path`;Type: String
The node is a shell execute string :
<?php
echo <<<STR
Hello $world
STR
;Type: String
The node contains a list of constref / variables / expr :
<?php
echo $foo->bar_$baz;Type: String
Extends Node
An array entry - see Array
Properties
Extends Node
Defines an error node (used only on silentMode)
Properties
Extends Statement
Defines an eval statement
Properties
sourceNode
Extends Statement
Defines an exit / die call
Properties
status(Node | null)
Extends Node
Any expression node. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern.
Extends Statement
Defines a for iterator
Properties
initArray<Expression>testArray<Expression>incrementArray<Expression>bodyStatementshortFormboolean
Extends Statement
Defines a foreach iterator
Properties
sourceExpressionkey(Expression | null)valueExpressionbodyStatementshortFormboolean
Extends Declaration
Defines a classic function
Properties
Extends Statement
Imports a variable from the global scope
Properties
Extends Statement
Defines goto statement
Properties
labelString
Extends Statement
Halts the compiler execution
Properties
afterString String after the halt statement
Extends Node
Defines an identifier node
Properties
This is an identifier without a namespace separator, such as Foo
Type: String
This is an identifier with a namespace separator, such as Foo\Bar
Type: String
This is an identifier with a namespace separator that begins with a namespace separator, such as \Foo\Bar. The namespace \Foo is also a fully qualified name.
Type: String
This is an identifier starting with namespace, such as namespace\Foo\Bar.
Type: String
Extends Statement
Defines a if statement
Properties
testExpressionbodyBlockalternate(Block | If | null)shortFormboolean
Extends Statement
Defines system include call
Properties
Extends Literal
Defines inline html output (treated as echo output)
Extends Declaration
An interface definition
Properties
extendsArray<Identifier>bodyArray<Declaration>
Extends Sys
Defines an isset call
Extends Node
A label statement (referenced by goto)
Properties
nameString
Extends Sys
Defines list assignment
Extends Expression
Defines an array structure
Properties
Defines the location of the node (with it's source contents as string)
Parameters
sourcestartend
Properties
Extends Expression
Lookup on an offset in the specified object
Properties
whatExpressionoffsetExpression
Extends Literal
Defines magic constant
Extends Function
Defines a class/interface/trait method
Properties
Extends Block
The main program node
Properties
Extends Statement
Creates a new instance of the specified class
Properties
what(Identifier | Variable | Class)argumentsArray<Arguments>
A generic AST node
Parameters
kindlocation
Properties
Helper for extending the Node class
Parameters
constructorFunction
Returns Function
Extends Literal
Defines a nowdoc string
Properties
labelString
Extends Literal
Defines a string (simple ou double quoted) - chars are already escaped
Properties
isDoubleQuoteboolean
Extends Literal
Defines a numeric value
Extends Lookup
Lookup on an offset in an array
Extends Expression
Defines binary operations
Extends Declaration
Defines a function parameter
Properties
type(Identifier | null)value(Node | null)byrefbooleanvariadicbooleannullableboolean
Extends Operation
Parenthesis encapsulation (... expr ...)
Properties
innerExpression
Each Position object consists of a line number (1-indexed) and a column number (0-indexed):
Parameters
linecolumnoffset
Properties
Extends Operation
Defines a post operation $i++ or $i--
Properties
Extends Operation
Defines a pre operation ++$i or --$i
Properties
Extends Sys
Outputs
Extends Block
The main program node
Properties
Extends Declaration
Defines a class property
Properties
Extends Lookup
Lookup to an object property
Extends Statement
Defines a short if statement that returns a value
Properties
testExpressiontrueExprExpressionfalseExprExpression
Extends Node
A continue statement
Properties
expr(Expression | null)
Extends Statement
Avoids to show/log warnings & notices from the inner expression
Properties
exprExpression
Extends Node
Any statement.
Extends Statement
Declares a static variable into the current scope
Properties
Extends Lookup
Lookup to a static property
Extends Statement
Defines a switch statement
Properties
testExpressionbodyBlockshortFormboolean
Extends Statement
Defines system based call
Properties
Extends Statement
Defines a throw statement
Properties
whatExpression
Extends Declaration
A trait definition
Properties
extends(Identifier | null)implementsArray<Identifier>bodyArray<Declaration>
Extends Node
Defines a trait alias
Properties
trait(Identifier | null)methodstringas(string | null)visibility(string | null)
Extends Node
Defines a trait alias
Properties
trait(Identifier | null)methodstringinsteadArray<Identifier>
Extends Node
Defines a trait usage
Properties
traitsArray<Identifier>adaptations(Array<Node> | null)
Extends Statement
Defines a try statement
Properties
Extends Operation
Unary operations
Properties
typeStringwhatExpression
Extends Sys
Deletes references to a list of variables
Extends Statement
Defines a use statement (with a list of use items)
Properties
Extends Statement
Defines a use statement (from namespace)
Properties
Importing a constant
Type: String
Importing a function
Type: String
Extends Expression
Any expression node. Since the left-hand side of an assignment may be any expression in general, an expression can also be a pattern.
Properties
name(String | Node) The variable name (can be a complex expression when the name is resolved dynamically)byrefboolean Indicate if the variable reference is used, ex&$foocurlyboolean Indicate if the name is defined between curlies, ex${foo}
Examples
// PHP code :
&$foo
// AST output
{
"kind": "variable",
"name": "foo",
"byref": true,
"curly": false
}Extends Expression
Introduce a list of items into the arguments of the call
Properties
what(Array | Expression)
Extends Statement
Defines a while statement
Properties
testExpressionbodyStatementshortFormboolean
Extends Expression
Defines a yield generator statement
Properties
value(Expression | Null)key(Expression | Null)
Extends Expression
Defines a yield from generator statement
Properties
valueExpression