Uzly stromu
Referenční přehled všech tříd uzlů PhpSyntax: popis a sloty s typem. Slot je pojmenovaný rolí, ne
textem (ifKeyword, openParen, body), párové oddělovače jsou vždy open* a
close*, seznamy jsou v množném čísle; ? značí slot, který může být prázdný.
Všechny třídy leží v PhpSyntax\Nodes. Slot typu Token drží jeden token,
NodeList<T> seznam uzlů bez oddělovačů, SeparatedNodeList<T> seznam s oddělovači
(čárky, středníky) mezi položkami. Jak strom číst a měnit, říkají stránky Strom a Úpravy.
Společné uzly
Kořen souboru, jména, seznamy, parametry, argumenty, atributy a části řídicích struktur.
NameNode
Name of a class, function, constant or namespace: one token of any kind, including keywords the grammar accepts as names (static, array, readonly).
token:Token
IdentifierNode
Identifier of a member, label, hook or alias: one token of any kind, including reserved words.
token:Token
ArgumentListNode
Parenthesized arguments of a call, instantiation, attribute or exit.
openParen:Tokenargs:SeparatedNodeList<ArgumentNode|VariadicPlaceholderNode>closeParen:Token
ArgumentNode
Argument of a call: optionally named, by reference or unpacked.
name:?IdentifierNodecolon:?TokenbyRef:?Tokenellipsis:?Tokenexpr:ExpressionNode
VariadicPlaceholderNode
The … placeholder of a first-class callable: f(…).
ellipsis:Token
ParameterNode
Parameter of a function, method, closure or hook; with modifiers it promotes a property.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodetype:?TypeNodebyRef:?Tokenellipsis:?Tokenvar:Expression\VariableNodeequals:?Tokendefault:?ExpressionNodeopenBrace:?Tokenhooks:?NodeList<Member\PropertyHookNode>closeBrace:?Token
AttributeGroupNode
One #[...] group of attributes.
openAttribute:Tokenattributes:SeparatedNodeList<AttributeNode>closeBracket:Token
AttributeNode
Attribute with optional arguments.
name:NameNodeargs:?ArgumentListNode
ModifiersNode
Modifier keywords in source order; may be empty.
tokens:list<Token>
FileNode
Root of the tree.
stmts:NodeList<StatementNode>eof:Token
AnonymousClassNode
Anonymous class in a new expression: new class(…) extends A implements B { … }. Implementuje
ClassLikeNode.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodeclassKeyword:Tokenargs:?ArgumentListNodeextendsKeyword:?Tokenextends:?NameNodeimplementsKeyword:?Tokenimplements:?SeparatedNodeList<NameNode>openBrace:Tokenmembers:NodeList<MemberNode>closeBrace:Token
ArrayItemNode
Item of an array literal or a destructuring list: value with optional key, by reference or unpacked.
key:?ExpressionNodedoubleArrow:?TokenbyRef:?Tokenellipsis:?Tokenvalue:ExpressionNode
EmptyArrayItemNode
Skipped item of a destructuring list ([, $b] = $x); has no tokens.
MatchArmNode
Arm of a match expression: conditions or default, and the result.
conds:?SeparatedNodeList<ExpressionNode>defaultKeyword:?TokendefaultComma:?TokendoubleArrow:Tokenbody:ExpressionNode
ClosureUsesNode
The use (…) clause of a closure.
useKeyword:TokenopenParen:Tokenvars:SeparatedNodeList<ClosureUseNode>closeParen:Token
ClosureUseNode
Variable captured by a closure, optionally by reference.
byRef:?Tokenvar:Expression\VariableNode
ElseIfNode
elseif branch, in either syntax.
elseifKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>
ElseNode
else branch, in either syntax; else if is an else with an if statement as the body.
elseKeyword:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>
CaseNode
case or default of a switch; the separator is a colon or a semicolon.
caseKeyword:Tokencond:?ExpressionNodeseparator:Tokenstmts:NodeList<StatementNode>
CatchNode
catch clause with one or more types and an optional variable.
catchKeyword:TokenopenParen:Tokentypes:SeparatedNodeList<NameNode>var:?Expression\VariableNodecloseParen:Tokenbody:Statement\BlockNode
FinallyNode
finally clause.
finallyKeyword:Tokenbody:Statement\BlockNode
DeclareItemNode
Directive of a declare statement: strict_types=1.
name:IdentifierNodeequals:Tokenvalue:ExpressionNode
StaticVarNode
Variable of a static statement with an optional initializer.
var:Expression\VariableNodeequals:?Tokendefault:?ExpressionNode
UseItemNode
Imported name with an optional alias; the type (function, const) appears only inside a group use.
type:?Tokenname:NameNodeasKeyword:?Tokenalias:?IdentifierNode
ConstItemNode
Constant of a const statement or a class constant declaration.
name:IdentifierNodeequals:Tokenvalue:ExpressionNode
Příkazy
Deklarace a příkazy: Statement\* jsou položky seznamu stmts souboru, bloku nebo jmenného
prostoru.
NamespaceNode
namespace declaration; after „namespace A;“ the following statements are nested in it.
namespaceKeyword:Tokenname:?NameNodesemicolon:?TokenopenBrace:?Tokenstmts:NodeList<StatementNode>closeBrace:?Token
UseNode
use import of classes, functions or constants.
useKeyword:Tokentype:?Tokenitems:SeparatedNodeList<UseItemNode>semicolon:Token
GroupUseNode
Group use import: use A\{B, C};.
useKeyword:Tokentype:?Tokenprefix:NameNodenamespaceSeparator:TokenopenBrace:Tokenitems:SeparatedNodeList<UseItemNode>closeBrace:Tokensemicolon:Token
ConstNode
const statement outside a class.
attributes:NodeList<AttributeGroupNode>constKeyword:Tokenitems:SeparatedNodeList<ConstItemNode>semicolon:Token
HaltCompilerNode
__halt_compiler(); the rest of the file is the data token.
haltKeyword:TokenopenParen:TokencloseParen:Tokensemicolon:Tokendata:?Token
InlineHtmlNode
Text outside PHP tags, including a BOM or a hashbang line.
html:Token
EmptyStatementNode
Bare semicolon, or a close tag after a terminated statement.
semicolon:Token
ExpressionStatementNode
Expression as a statement.
expr:ExpressionNodesemicolon:Token
BlockNode
Statements in braces.
openBrace:Tokenstmts:NodeList<StatementNode>closeBrace:Token
IfNode
if statement in either syntax; the body is a statement, the alternative syntax fills stmts.
ifKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>elseifs:NodeList<ElseIfNode>else:?ElseNodeendKeyword:?Tokensemicolon:?Token
WhileNode
while loop in either syntax.
whileKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>endKeyword:?Tokensemicolon:?Token
DoWhileNode
do-while loop.
doKeyword:Tokenbody:StatementNodewhileKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:Tokensemicolon:Token
ForNode
for loop in either syntax.
forKeyword:TokenopenParen:Tokeninit:SeparatedNodeList<ExpressionNode>initSemicolon:Tokencond:SeparatedNodeList<ExpressionNode>condSemicolon:Tokenloop:SeparatedNodeList<ExpressionNode>closeParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>endKeyword:?Tokensemicolon:?Token
ForeachNode
foreach loop in either syntax; the value may be a variable, a list or an array pattern.
foreachKeyword:TokenopenParen:Tokenexpr:ExpressionNodeasKeyword:TokenkeyVar:?ExpressionNodedoubleArrow:?TokenbyRef:?TokenvalueVar:ExpressionNodecloseParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>endKeyword:?Tokensemicolon:?Token
SwitchNode
switch statement in either syntax; a semicolon may precede the first case.
switchKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:TokenopenBrace:?Tokencolon:?TokenleadingSemicolon:?Tokencases:NodeList<CaseNode>closeBrace:?TokenendKeyword:?Tokensemicolon:?Token
BreakNode
break with an optional level.
breakKeyword:Tokenexpr:?ExpressionNodesemicolon:Token
ContinueNode
continue with an optional level.
continueKeyword:Tokenexpr:?ExpressionNodesemicolon:Token
ReturnNode
return with an optional value.
returnKeyword:Tokenexpr:?ExpressionNodesemicolon:Token
GlobalNode
global statement.
globalKeyword:Tokenvars:SeparatedNodeList<ExpressionNode>semicolon:Token
StaticNode
static variable declaration.
staticKeyword:Tokenvars:SeparatedNodeList<StaticVarNode>semicolon:Token
EchoNode
echo statement; the keyword may be the <?= open tag and the semicolon a close tag.
echoKeyword:Tokenexprs:SeparatedNodeList<ExpressionNode>semicolon:Token
UnsetNode
unset statement.
unsetKeyword:TokenopenParen:Tokenvars:SeparatedNodeList<ExpressionNode>closeParen:Tokensemicolon:Token
DeclareNode
declare statement in its three forms: with a body, with a bare semicolon, or with the alternative syntax.
declareKeyword:TokenopenParen:Tokenitems:SeparatedNodeList<DeclareItemNode>closeParen:Tokenbody:?StatementNodecolon:?Tokenstmts:?NodeList<StatementNode>endKeyword:?Tokensemicolon:?Token
TryNode
try statement with catches and an optional finally.
tryKeyword:Tokenbody:Statement\BlockNodecatches:NodeList<CatchNode>finally:?FinallyNode
GotoNode
goto statement.
gotoKeyword:Tokenlabel:IdentifierNodesemicolon:Token
LabelNode
Label for goto.
name:IdentifierNodecolon:Token
FunctionNode
Function declaration.
attributes:NodeList<AttributeGroupNode>functionKeyword:TokenbyRef:?Tokenname:IdentifierNodeopenParen:Tokenparams:SeparatedNodeList<ParameterNode>closeParen:Tokencolon:?TokenreturnType:?TypeNodebody:Statement\BlockNode
ClassNode
Class declaration. Implementuje ClassLikeNode.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodeclassKeyword:Tokenname:IdentifierNodeextendsKeyword:?Tokenextends:?NameNodeimplementsKeyword:?Tokenimplements:?SeparatedNodeList<NameNode>openBrace:Tokenmembers:NodeList<MemberNode>closeBrace:Token
InterfaceNode
Interface declaration. Implementuje ClassLikeNode.
attributes:NodeList<AttributeGroupNode>interfaceKeyword:Tokenname:IdentifierNodeextendsKeyword:?Tokenextends:?SeparatedNodeList<NameNode>openBrace:Tokenmembers:NodeList<MemberNode>closeBrace:Token
TraitNode
Trait declaration. Implementuje ClassLikeNode.
attributes:NodeList<AttributeGroupNode>traitKeyword:Tokenname:IdentifierNodeopenBrace:Tokenmembers:NodeList<MemberNode>closeBrace:Token
EnumNode
Enum declaration, optionally backed by a scalar type. Implementuje ClassLikeNode.
attributes:NodeList<AttributeGroupNode>enumKeyword:Tokenname:IdentifierNodecolon:?TokenscalarType:?TypeNodeimplementsKeyword:?Tokenimplements:?SeparatedNodeList<NameNode>openBrace:Tokenmembers:NodeList<MemberNode>closeBrace:Token
Výrazy
Vše, co má hodnotu: operátory, volání, přístupy, přiřazení, closures.
VariableNode
Variable: $a, $$a, ${expr}; inside a string also a bare name in ${name}.
dollar:?TokenopenBrace:?Tokenname:Token|ExpressionNodecloseBrace:?Token
ArrayDimFetchNode
Array or string offset access: $a[$i], $a[].
var:ExpressionNodeopenBracket:Tokendim:?ExpressionNodecloseBracket:Token
PropertyFetchNode
Property access with → or ?->; the name may be an identifier, a variable or a braced expression.
object:ExpressionNodeoperator:TokenopenBrace:?Tokenname:IdentifierNode|ExpressionNodecloseBrace:?Token
StaticPropertyFetchNode
Static property access: A::$b.
class:NameNode|ExpressionNodedoubleColon:Tokenname:Expression\VariableNode
ClassConstantFetchNode
Class constant access: A::B, A::class, A::{expr}.
class:NameNode|ExpressionNodedoubleColon:TokenopenBrace:?Tokenname:IdentifierNode|ExpressionNodecloseBrace:?Token
ConstantFetchNode
Constant access by name: FOO, \Foo\BAR, true.
name:NameNode
FunctionCallNode
Function call by name or on an expression.
name:NameNode|ExpressionNodeargs:ArgumentListNode
MethodCallNode
Method call with → or ?->.
object:ExpressionNodeoperator:TokenopenBrace:?Tokenname:IdentifierNode|ExpressionNodecloseBrace:?Tokenargs:ArgumentListNode
StaticCallNode
Static method call: A::b(), $a::b(), A::{expr}().
class:NameNode|ExpressionNodedoubleColon:TokenopenBrace:?Tokenname:IdentifierNode|ExpressionNodecloseBrace:?Tokenargs:ArgumentListNode
NewNode
Instantiation of a named, dynamic or anonymous class.
newKeyword:Tokenclass:NameNode|ExpressionNode|AnonymousClassNodeargs:?ArgumentListNode
ArrayNode
Array literal in either syntax: [...] or array(…); on the left of an assignment it destructures.
arrayKeyword:?TokenopenDelimiter:Tokenitems:SeparatedNodeList<ArrayItemNode|EmptyArrayItemNode>closeDelimiter:Token
ListNode
Destructuring with list(…).
listKeyword:TokenopenParen:Tokenitems:SeparatedNodeList<ArrayItemNode|EmptyArrayItemNode>closeParen:Token
AssignNode
Assignment, plain or compound (+=, ??=); the operator token tells which.
var:ExpressionNodeoperator:Tokenexpr:ExpressionNode
AssignRefNode
Assignment by reference: $a = &$b.
var:ExpressionNodeequals:Tokenampersand:Tokenexpr:ExpressionNode
BinaryNode
Binary operation; the operator token tells which (arithmetic, comparison, logical, bitwise, concatenation, coalesce, pipe).
left:ExpressionNodeoperator:Tokenright:ExpressionNode
UnaryNode
Prefix operation: +, -, !, ~, @, ++, –.
operator:Tokenexpr:ExpressionNode
PostfixNode
Postfix increment or decrement.
expr:ExpressionNodeoperator:Token
CastNode
Type cast; the cast token keeps its spelling including inner whitespace: ( int ).
cast:Tokenexpr:ExpressionNode
TernaryNode
Ternary conditional ($cond ? $if : $else) or the elvis form ($cond ?: $else).
cond:ExpressionNodequestion:Tokenif:?ExpressionNodecolon:Tokenelse:ExpressionNode
InstanceofNode
instanceof check against a name or a dynamic class.
expr:ExpressionNodeinstanceofKeyword:Tokenclass:NameNode|ExpressionNode
ParenthesizedNode
Expression in parentheses.
openParen:Tokenexpr:ExpressionNodecloseParen:Token
IssetNode
isset(…) with one or more variables.
issetKeyword:TokenopenParen:Tokenvars:SeparatedNodeList<ExpressionNode>closeParen:Token
EmptyNode
empty(…).
emptyKeyword:TokenopenParen:Tokenexpr:ExpressionNodecloseParen:Token
EvalNode
eval(…).
evalKeyword:TokenopenParen:Tokenexpr:ExpressionNodecloseParen:Token
IncludeNode
include, include_once, require or require_once; the keyword token tells which.
includeKeyword:Tokenexpr:ExpressionNode
ExitNode
exit or die with optional arguments.
exitKeyword:Tokenargs:?ArgumentListNode
PrintNode
print expression.
printKeyword:Tokenexpr:ExpressionNode
YieldNode
yield, yield $value or yield $key ⇒ $value.
yieldKeyword:Tokenkey:?ExpressionNodedoubleArrow:?Tokenvalue:?ExpressionNode
YieldFromNode
yield from expression.
yieldFromKeyword:Tokenexpr:ExpressionNode
ThrowNode
throw expression.
throwKeyword:Tokenexpr:ExpressionNode
CloneNode
clone expression; clone(…) with arguments is a function call.
cloneKeyword:Tokenexpr:ExpressionNode
MatchNode
match expression.
matchKeyword:TokenopenParen:Tokencond:ExpressionNodecloseParen:TokenopenBrace:Tokenarms:SeparatedNodeList<MatchArmNode>closeBrace:Token
ClosureNode
Anonymous function, optionally static, with captured variables.
attributes:NodeList<AttributeGroupNode>staticKeyword:?TokenfunctionKeyword:TokenbyRef:?TokenopenParen:Tokenparams:SeparatedNodeList<ParameterNode>closeParen:Tokenuses:?ClosureUsesNodecolon:?TokenreturnType:?TypeNodebody:Statement\BlockNode
ArrowFunctionNode
Arrow function fn(…) ⇒ expr, optionally static.
attributes:NodeList<AttributeGroupNode>staticKeyword:?TokenfnKeyword:TokenbyRef:?TokenopenParen:Tokenparams:SeparatedNodeList<ParameterNode>closeParen:Tokencolon:?TokenreturnType:?TypeNodedoubleArrow:Tokenexpr:ExpressionNode
ShellExecNode
Command in backticks with interpolation.
openBacktick:Tokenparts:NodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>closeBacktick:Token
Členy tříd
Vlastnosti, konstanty, metody, případy výčtu, hooky a použití traitů.
PropertyNode
Property declaration; one or more properties, optionally with hooks.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodetype:?TypeNodeitems:SeparatedNodeList<Member\PropertyItemNode>semicolon:?TokenopenBrace:?Tokenhooks:?NodeList<Member\PropertyHookNode>closeBrace:?Token
PropertyItemNode
One property of a declaration with an optional default. Rozšiřuje Node.
name:Tokenequals:?Tokendefault:?ExpressionNode
PropertyHookNode
Property hook (get, set) with a block body, an arrow body or none. Rozšiřuje Node.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodebyRef:?Tokenname:IdentifierNodeopenParen:?Tokenparams:?SeparatedNodeList<ParameterNode>closeParen:?Tokenbody:?Statement\BlockNodedoubleArrow:?Tokenexpr:?ExpressionNodesemicolon:?Token
ClassConstNode
Class constant declaration, optionally typed.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodeconstKeyword:Tokentype:?TypeNodeitems:SeparatedNodeList<ConstItemNode>semicolon:Token
MethodNode
Method declaration; abstract and interface methods end with a semicolon instead of a body.
attributes:NodeList<AttributeGroupNode>modifiers:ModifiersNodefunctionKeyword:TokenbyRef:?Tokenname:IdentifierNodeopenParen:Tokenparams:SeparatedNodeList<ParameterNode>closeParen:Tokencolon:?TokenreturnType:?TypeNodebody:?Statement\BlockNodesemicolon:?Token
TraitUseNode
use of traits with optional adaptations in braces.
useKeyword:Tokentraits:SeparatedNodeList<NameNode>semicolon:?TokenopenBrace:?Tokenadaptations:?NodeList<Member\TraitPrecedenceNode|Member\TraitAliasNode>closeBrace:?Token
TraitPrecedenceNode
Trait adaptation A::m insteadof B;. Rozšiřuje Node.
trait:NameNodedoubleColon:Tokenmethod:IdentifierNodeinsteadofKeyword:Tokentraits:SeparatedNodeList<NameNode>semicolon:Token
TraitAliasNode
Trait adaptation m as [modifier] [alias];. Rozšiřuje Node.
trait:?NameNodedoubleColon:?Tokenmethod:IdentifierNodeasKeyword:Tokenmodifier:?Tokenalias:?IdentifierNodesemicolon:Token
EnumCaseNode
Enum case with an optional backing value.
attributes:NodeList<AttributeGroupNode>caseKeyword:Tokenname:IdentifierNodeequals:?Tokenvalue:?ExpressionNodesemicolon:Token
Skaláry
Čísla, řetězce a jejich interpolace, magické konstanty; text zůstává tak, jak byl zapsán.
IntegerNode
Integer literal in any base, kept as written.
token:Token
FloatNode
Floating-point literal, kept as written.
token:Token
StringNode
String literal without interpolation, quotes included; inside an interpolated string also a bare offset name
($a[key]).
token:Token
MagicConstantNode
Magic constant: __LINE__, __FILE__, __DIR__, __CLASS__, __TRAIT__, __METHOD__, __FUNCTION__, __PROPERTY__, __NAMESPACE__.
token:Token
InterpolatedStringNode
Double-quoted string with interpolated variables or expressions.
openQuote:Tokenparts:NodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>closeQuote:Token
HeredocNode
Heredoc or nowdoc; the closing delimiter keeps its indentation, the parts keep theirs.
openDelimiter:Tokenparts:NodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>closeDelimiter:Token
InterpolatedStringPartNode
Literal text between interpolations, whitespace included. Rozšiřuje Node.
text:Token
InterpolationNode
Braced interpolation inside a string: {$expr} or ${name}. Rozšiřuje Node.
openBrace:Tokenexpr:ExpressionNodecloseBrace:Token
Typy
Typové deklarace parametrů, vlastností a návratových hodnot.
NamedTypeNode
Type given by a name: builtin (int, static, array, callable) or a class.
name:NameNode
NullableTypeNode
Nullable type: ?T.
question:Tokentype:TypeNode
UnionTypeNode
Union type A|B; a member may be a parenthesized intersection (DNF).
types:SeparatedNodeList<TypeNode>
IntersectionTypeNode
Intersection type A&B, parenthesized inside a union.
openParen:?Tokentypes:SeparatedNodeList<TypeNode>closeParen:?Token