Přehled uzlů

Referenční přehled všech tříd uzlů: popis, sloty i s typem a veřejné vlastnosti a metody. Slot je pojmenovaný podle role, ne podle textu (ifKeyword, openParen, body), párové oddělovače jsou vždy open* a close*, seznam uzlů má jméno v množném čísle (statements, members) a ? značí slot, který může být prázdný.

Třídy leží v PhpSyntax\Nodes a jeho podprostorech Statement, Expression, Member, Scalar a Type; jména v typech jsou psaná relativně k PhpSyntax\Nodes (Expression\VariableNode), třídy mimo něj relativně k PhpSyntax (Token). Slot typu Token drží jeden token, PlainNodeList<T> seznam uzlů bez oddělovačů a SeparatedNodeList<T> seznam s oddělovači mezi položkami, oba podtypy NodeList<T>: čárkami, svislítky ve sjednocení typů a v catch a ampersandy v průniku typů. U každé třídy jsou nejdřív sloty a pak konstanty, vlastnosti a metody, které třída sama přidává; co umí každý uzel, je u Node, co každý výraz, u ExpressionNode. Popisy jsou převzaté z dokumentačních komentářů v kódu, proto jsou anglicky. Jak strom číst a měnit, říkají stránky Uzly a sloty a Úpravy stromu.

Bázové třídy a rozhraní

Předci a rozhraní, podle kterých se uzly hledají a filtrují ($file->find(ExpressionNode::class)). Node leží v PhpSyntax, TraitAdaptationNode v PhpSyntax\Nodes\Member a ostatní v PhpSyntax\Nodes.

Node

Node of the concrete syntax tree; every token of the source is reachable through the children. The nodes and the lists are the library's own: a class extending one or implementing an interface of the nodes elsewhere is not supported, so the protected members, the machinery of the writes, are internal.

  • $parent: ?Node – The node this one belongs to; only the tree writes it.
  • $text: string – The node as it is written, without the trivia on its outer edges, which printing it writes too.
  • $leadingTrivia: list<Trivia> – The trivia before the node, which are the leading trivia of its first token; setEdgeTrivia() writes them.
  • $trailingTrivia: list<Trivia> – The trivia after the node, which are the trailing trivia of its last token; setEdgeTrivia() writes them.
  • getChildren(): list<Node|Token> – Children in source order, without empty slots.
  • replaceChild(Node|Token $old, Node|Token $new): void – Replaces a direct child; the new one must fit the type of the slot.
  • findSlotOf(Node|Token $child): ?string – The slot the direct child stands in; null when it is not a child. A list and ModifiersNode answer with the collection their child is in, items, separators or tokens, which is read, not a slot to write.
  • getFile(): ?FileNode
  • getTokens(): list<Token> – The tokens of the whole subtree in source order; empty for a node without tokens, such as an empty list.
  • getTokenTexts(): list<string> – The texts of the tokens of the subtree in source order, the trivia left out: what matches() compares two nodes by, and what a tool keys a map by where the layout of the code must not count. The size of the code is measured on $text, which keeps the layout.
  • getFirstToken(): ?Token – Null only for a node without tokens.
  • getLastToken(): ?Token
  • getStartLine(): ?int – Current line of the first token; null for a detached subtree or a node without tokens.
  • getEndLine(): ?int – Current line where the last token ends; null as for getStartLine().
  • isMultiLine(): bool – Whether a line ends inside the text of the node, the trivia on its outer edges left out; unlike the lines, it needs no file.
  • getOffsetRange(): ?array{int, int} – Byte offsets of the node in the current text of the file, the end exclusive; null as for getStartLine().
  • getDocComment(): ?Trivia – Doc comment before the node: the last one in the leading trivia of the first token, or in the trailing trivia of the previous token, where a doc comment stands between two declarations on one line.
  • replaceTrivia(Trivia $old, Trivia $new): void – Replaces one trivia of the node, wherever among its tokens it stands, with another in place.
  • removeTrivia(Trivia $trivia): void – Removes one trivia of the node, wherever among its tokens it stands, tidying the whitespace around it the way Token::removeTrivia() does.
  • replaceDocComment(Trivia $docComment): void – Replaces the doc comment of the node (see getDocComment()) with the trivia given.
  • removeDocComment(): void – Removes the doc comment of the node (see getDocComment()) together with the line it stands on.
  • findAncestor(class-string<T> $class): (T&Node)|null
  • findFirst(class-string<T> $class, ?callable $predicate = null): (T&Node)|null – The first descendant of the class the predicate accepts, in pre-order; null when there is none.
  • find(class-string<T> $class, ?callable $predicate = null): list<T&Node> – Descendant nodes of the class the predicate accepts, in pre-order, as a snapshot safe to iterate while mutating the tree.
  • matches(Node $other): bool – Whether the tokens of both nodes carry the same texts, whatever the whitespace between them.
  • hasInnerComment(): bool – Whether a comment sits anywhere between the first and the last token of the node; the trivia on its outer edges do not count.
  • getInnerComments(): list<Trivia> – The comments inside the node, in source order; those on its outer edges are not among them, the same way hasInnerComment() does not count them.
  • setEdgeTrivia(?list<Trivia> $leading = null, ?list<Trivia> $trailing = null): static – Writes the trivia on the outer edges of the node: before its first token and after its last one. A null leaves that edge alone, [] clears it, and a node without tokens takes neither.
  • withoutEdgeTrivia(): static – A deep copy without a parent and without the trivia on its outer edges, which belong to the place it was copied from.
  • replaceWith(Node $node): void – Replaces this node in its parent; the trivia around the old node stay in place around the new one, or with the tokens on either side when the new one has no tokens, an empty list, and where the new one then stands right against a token it would be read together with, . against 1 or return against FOO, a space keeps the two apart.
  • remove(CommentPolicy $comments = CommentPolicy::MoveToNextToken): void – Removes this node from its list, together with the separator that goes with it. A node alone on its lines takes the lines with it (indentation and line ending), otherwise the whitespace around stays; its comments, those on its edges included, go where the policy says, each with its indentation and the line ending after it.
  • __toString(): string – The node printed back to source, the trivia on its outer edges included; $text leaves them out.

AttributeAwareNode

Declaration that may carry attributes, its list empty where none is written: a class-like or a function-like one, a member, a constant, an enum case, a parameter; an interface, because they share no base class.

  • $attributes: PlainNodeList<AttributeGroupNode>

ClassLikeNode

Declaration with members: class, interface, trait, enum, anonymous class; an interface, because an anonymous class stands inside a new expression and the rest are statements.

  • $name: ?IdentifierNode
  • $members: PlainNodeList<MemberNode>

ExpressionNode

Expression, which stands for a value; a destructuring stands where a target is written and is a ListNode, not one of these. Rozšiřuje Node.

  • getDereferenceKind(): ?DereferenceKind – How the parent reaches into this expression, null where it does not: $this->x, $this->y() and $this[0] fetch from it, $this() calls it, $this::y() takes it for the name of a class.
  • isDereferenced(): bool – Whether the parent reads a member, an element or a static member of this expression, or calls it: $this->x, $this[0], $this::y(), $this(). Such an expression needs parentheses unless the grammar makes it a primary one.
  • isDereferenceable(DereferenceKind $by = DereferenceKind::Fetch): bool – Whether what is written after the expression may reach into it with no parentheses around it. A call takes a name or a member written before it for its own, which calls another thing entirely, and :: takes the name of a class, which a name written there would become.
  • isWritable(): bool – Whether the expression may stand where a place is assigned to: a variable, an element, a property, reached through a chain PHP writes through. A ?-> anywhere along it rules the write out, a call in the chain included, and so does a chain starting at a value of its own, a literal, a constant, new or clone, which has no place to write to. It says nothing about reading; that is isRepeatableRead(), and the two answer for the two sides of =.
  • isWritten(): bool – Whether something writes the expression or an element of it, a variable, a property or an element alike: it is assigned, stepped, unset, bound, or taken by reference, either side of =& among them, the right one becoming a reference a write may later go through.
  • isRepeatableRead(): bool – Whether reading the expression again gives the same value with no side effects: variables, property, constant and offset fetches, literals, arrays of such items and what parentheses or a unary operator make of them, nothing that runs code of its own; an unpacked item may run a generator and one by reference creates the variable, so neither is repeatable. The answer is syntactic, so what the language runs behind such a read is out of sight and does not count: a magic getter or a property hook behind a fetch, an ArrayAccess behind an offset, a __toString() behind a string that interpolates. Whoever cannot assume that much has to know the types, which a syntax tree does not.
  • isBoolean(): bool – Whether the expression yields a boolean whatever its operands: a comparison, a logical operation, a negation, instanceof, isset(), empty(), a bool cast or a boolean literal.
  • toValue(): mixed – The value the expression is written as: a scalar, null, true, false, or an array of them. A name standing for a constant is not one, its value being a matter of what the code around it defines. Throws LogicException where the expression is written as no value; hasValue() tells beforehand.
  • hasValue(): bool – Whether the expression is written as a value, which is what toValue() gives.
  • replaceWithExpression(ExpressionNode $expression): void – Replaces this node by the expression the way replaceWith() does, in parentheses where the expression binds looser than the place asks or is reached into there: what ParenthesizedNode::isRedundant() does not call needless stays. A place typed narrower, which takes no parentheses, gets the expression bare.

FunctionLikeNode

Declaration with parameters and a body: function, method, closure, arrow function, property hook; an interface, because a closure and an arrow function are expressions and the rest are not.

  • $parameters: ?SeparatedNodeList<ParameterNode> – Null for a property hook written without parentheses.
  • $returnType: ?TypeNode – The return type declared; null where none is, a property hook having none to declare.

MemberNode

Member of a class-like declaration: property, constant, method, trait use, enum case. Rozšiřuje Node.

NodeList

Sequence of nodes, plain or separated by tokens. It has no slots and reads its items itself, and it is read as a collection: iterated, counted and indexed ($list[0]), getItems() giving the items as an array. It changes only through its own methods. Rozšiřuje Node. Implementuje Countable, IteratorAggregate, ArrayAccess. Typ položek T je podtyp Node.

  • getItems(): list<T>
  • isEmpty(): bool
  • append(T $item): void
  • insert(int $index, T $item): void
  • removeItem(Node $item): void – Takes the item out with its trivia and tidies nothing; Node::remove() takes the lines with it.
  • indexOf(Node $item): int
  • count(): int
  • getIterator(): ArrayIterator<int, T> – The items, as a snapshot safe to iterate while mutating the list.
  • offsetExists(mixed $offset): bool
  • offsetGet(mixed $offset): T
  • offsetSet(mixed $offset, mixed $value): never
  • offsetUnset(mixed $offset): never

OperatorNode

Expression written with an operator, which is what decides whether parentheses around it are needed. Those whose right operand reaches as far as the code lets it, an arrow function among them, are a RightExtendingNode.

  • getPrecedence(): int – How tightly the operator binds, the higher the tighter, in the order the precedence declarations of the grammar put the operators; only the order of the numbers is meant, not their values.
  • getAssociativity(): Associativity – Which side the operator leans to, where an operand of the same precedence may stand.

RightExtendingNode

Operator written with no left operand, whose right one reaches as far as the code lets it: fn() => …, throw, print, yield, yield from and include. It can capture nothing before itself, so it stands bare however loosely it binds, unless an operator follows it, which its operand would take in; before one it needs parentheses. Rozšiřuje OperatorNode.

ScalarNode

Literal written in the source: a number, a string in any of its delimiters, an interpolated string, a boolean, null and a magic constant. What it stands for is hasValue() and toValue(), which an interpolating string and a magic constant answer no to, standing for what the code around them says. Rozšiřuje ExpressionNode.

StatementNode

Statement: what a file, a block and the body of a control structure consist of. Rozšiřuje Node.

  • interruptsFlow(): bool – Whether the code does not go on after the statement: return, break, continue, goto, throw or exit. It reads the statement itself, so an if whose every branch returns is no such statement; that is control flow.

TraitAdaptationNode

What a trait use says about a method it takes from a trait: an alias or a precedence. The trait slot is left to the two subclasses, an alias being able to leave it out where a precedence has to name it. Rozšiřuje Node.

  • $method: IdentifierNode
  • $semicolon: Token

TypeNode

Type written in a declaration: a name, a nullable, a union or an intersection. Rozšiřuje Node.

  • isNullable(): bool – Whether the type accepts null: ?T, a union with null, and mixed.

Společné uzly

Kořen souboru, jména, seznamy, parametry, argumenty, atributy a části řídicích struktur; leží přímo v PhpSyntax\Nodes.

NameNode

Name of a class, function, constant or namespace: one token of any kind, including keywords the grammar accepts as names (static, array, readonly). Rozšiřuje Node.

  • token: Token
  • $text: string – The name as it is written, the leading backslash and the namespace prefix included. Writing it replaces the token with the one the name is written as, so that a qualified name does not stay an identifier; the trivia around it and its place in the original file stay with it.
  • $form: NameForm
  • $parts: list<string> – Segments of the name without the leading backslash or the namespace prefix.
  • $shortName: string – The last segment, which is what an import of the name brings in.
  • $symbolKind: SymbolKind – Which table of names the name belongs to: functions when called, constants when fetched, what a use item imports, otherwise classes, a namespace among them. It follows the place in the tree, so moving the node changes it, and it says nothing about whether the name refers to a symbol or declares one, which is isReference(): whoever resolves names asks that first.
  • static fromText(string $text): NameNode – A name written as the text, in the token the name is written as (Foo, A\B, \A\B, namespace\B); a keyword passes as well, the grammar taking one as a name in some places, whether or not it can name a symbol here.
  • isKeyword(): bool – Whether the name is a keyword the grammar accepts in place of a name (static, array, readonly, exit…).
  • isSpecialClass(): bool – Whether the name is self, static or parent, which stand for a class only where they are written.
  • isDeclaration(): bool – Whether the name declares or imports a symbol instead of referring to one: a namespace statement or a use.
  • isReference(): bool – Whether the name refers to a symbol of its table, one the resolver looks up: not the name a use or a namespace statement introduces, not self, static or parent where a class is named, which stand for one only where they are written, and not a builtin type where a type is written. A keyword read as a name refers where it stands for a symbol, as readonly(...) calls a function of that name, and so does self() or the constant parent.
  • equals(string $name): bool – Whether the name is written the same, letter case aside where PHP ignores it: a constant is compared exactly, its namespace too, although PHP ignores the case there; a class, a function and a namespace are not. The leading backslash is part of the writing and so part of the comparison; whether two names mean the same class is what NameResolver answers.

IdentifierNode

Identifier of a declaration, member, label, hook, alias or named argument: one token of any kind, including keywords. Rozšiřuje Node.

  • token: Token
  • $text: string – The identifier as it is written; whether its letter case matters is up to what it names, which equals() knows. Writing it takes an identifier and nothing else, so that no whitespace ends up in the text of a token.
  • static fromText(string $text): IdentifierNode – An identifier written as the text, which takes an identifier and nothing else.
  • equals(string $name): bool – Whether the identifier is written the same, letter case aside where PHP ignores it, which it does for what names a function, a method, a class and their kin, and for class after ::; a property, a constant, an enum case, a label and a named argument are compared exactly, and so is an identifier standing nowhere.

ArgumentListNode

Parenthesized arguments of a call, instantiation, attribute or exit. Rozšiřuje Node.

  • openParen: Token
  • items: SeparatedNodeList<ArgumentNode|VariadicPlaceholderNode|ArgumentPlaceholderNode>
  • closeParen: Token
  • static of(ExpressionNode ...$values): ArgumentListNode – A one-line list of positional arguments with the values, which lose the trivia on their edges.
  • isPartialApplication(): bool – Whether the list leaves parameters unbound with ? or ..., which makes a closure of the call instead of calling it.
  • findArgument(?string $name, ?int $position): ?ArgumentNode – The argument the parameter of the name and the position gets: the one written with the name, else the one standing at the position, so that get_class(object: $o) reads as the call get_class($o) is. Null where the parameter gets none, and where the call does not say which it gets: a ? placeholder holds a place without being an argument, and an unpacked array stands for as many arguments as it holds, so it takes the answer from a position after it, never from a name, which stands for itself. Whoever knows only one of the two asks with null for the other: the position alone finds no argument written with a name, the name alone none that is not.

ArgumentNode

Argument of a call: optionally named, by reference or unpacked. Rozšiřuje Node.

  • name: ?IdentifierNode
  • colon: ?Token
  • ampersand: ?Token
  • ellipsis: ?Token
  • value: ExpressionNode

VariadicPlaceholderNode

The ... placeholder of a first-class callable or a partial application: f(...), f($a, ...). Rozšiřuje Node.

  • ellipsis: Token

ArgumentPlaceholderNode

The ? placeholder of a partial function application, optionally named: f(?), f(name: ?). Rozšiřuje Node.

  • name: ?IdentifierNode
  • colon: ?Token
  • question: Token

ParameterNode

Parameter of a function, method, closure, arrow function or hook; with modifiers it promotes a property. Rozšiřuje Node. Implementuje AttributeAwareNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • type: ?TypeNode
  • ampersand: ?Token
  • ellipsis: ?Token
  • variable: Expression\VariableNode
  • equals: ?Token
  • default: ?ExpressionNode
  • openBrace: ?Token
  • hooks: ?PlainNodeList<Member\PropertyHookNode>
  • closeBrace: ?Token
  • isPromoted(): bool – Whether the parameter declares a property of the class, which its modifiers make it do.

AttributeGroupNode

One #[...] group of attributes. Rozšiřuje Node.

  • openBracket: Token
  • items: SeparatedNodeList<AttributeNode>
  • closeBracket: Token

AttributeNode

Attribute with optional arguments. Rozšiřuje Node.

  • name: NameNode
  • arguments: ?ArgumentListNode

ModifiersNode

Modifier keywords in source order (public, static, readonly, abstract, final, var, public(set)…); may be empty. Rozšiřuje Node. Implementuje Countable, IteratorAggregate.

  • $visibility: ?Visibility – The visibility the modifiers declare, null when they declare none, which leaves a member public, a promoted parameter too.
  • $writeVisibility: ?Visibility – The visibility for writing, which asymmetric visibility declares apart: public(set) and its kin.
  • isStatic(): bool
  • isAbstract(): bool
  • isFinal(): bool
  • isReadonly(): bool
  • findToken(int $kind): ?Token – The modifier token of the kind, null when the modifiers do not have it.
  • isEmpty(): bool
  • has(int $kind): bool
  • append(Token $token): void – Appends a modifier. The first one opens the declaration, so it takes over the leading trivia of the token it now stands before, the open tag and the doc comment among them; one without trailing trivia is kept apart from what follows by a space.
  • removeToken(Token $token): void – Removes a modifier. Its leading trivia go to the token after it, which may now open the declaration, and a comment after it stays: after the modifier before it, or on a line of its own above the token after it. A line the modifier ended after another token ends with that token now, which takes the line ending.
  • count(): int
  • getIterator(): ArrayIterator<int, Token> – The modifier tokens, as a snapshot safe to iterate while mutating them.

PlainNodeList

Sequence of nodes without separators: statements, members, attribute groups. Rozšiřuje NodeList. Implementuje ArrayAccess, IteratorAggregate, Countable. Typ položek T je podtyp Node.

SeparatedNodeList

Sequence of nodes with separator tokens between them and an optional trailing separator: parameters, arguments, array items, imports. An item may be an empty node standing for nothing between two separators ([, $b] = $x). Rozšiřuje NodeList. Implementuje ArrayAccess, IteratorAggregate, Countable. Typ položek T je podtyp Node.

  • getSeparators(): list<Token>
  • hasTrailingSeparator(): bool
  • setTrailingSeparator(?Token $separator): static

FileNode

Root of the tree: the statements of a file and the end-of-file token carrying the trailing trivia. Rozšiřuje Node.

  • statements: PlainNodeList<StatementNode>
  • endOfFile: Token
  • $revision: int – Version of the tree: every write to a slot, a list, or the text or trivia of a token that changes it increments it.
  • findNode(int $start, int $end, class-string<T> $class = 'PhpSyntax\\Node'): ?T – The outermost node of the class whose text stands exactly at the byte offsets of the current text, the end exclusive; the way a position of another tool (a parser of its own, an editor) is brought to the tree.

AnonymousClassNode

Anonymous class in a new expression: new class(...) extends A implements B { ... }. Rozšiřuje Node. Implementuje AttributeAwareNode, ClassLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • classKeyword: Token
  • arguments: ?ArgumentListNode
  • extendsKeyword: ?Token
  • extends: ?NameNode
  • implementsKeyword: ?Token
  • implements: ?SeparatedNodeList<NameNode>
  • openBrace: Token
  • members: PlainNodeList<MemberNode>
  • closeBrace: Token
  • $name: ?IdentifierNode

ArrayItemNode

Item of an array literal or a destructuring list: value with optional key, by reference or unpacked. Rozšiřuje Node.

  • key: ?ExpressionNode
  • doubleArrow: ?Token
  • ampersand: ?Token
  • ellipsis: ?Token
  • value: ExpressionNode|ListNode

EmptyArrayItemNode

Skipped item of a destructuring list ([, $b] = $x); has no tokens. Rozšiřuje Node.

MatchArmNode

Arm of a match expression: the values compared with the subject, or default, and the result. Rozšiřuje Node.

  • values: ?SeparatedNodeList<ExpressionNode>
  • defaultKeyword: ?Token
  • defaultComma: ?Token
  • doubleArrow: Token
  • result: ExpressionNode

ClosureUsesNode

The use (...) clause of a closure. Rozšiřuje Node.

  • useKeyword: Token
  • openParen: Token
  • variables: SeparatedNodeList<ClosureUseNode>
  • closeParen: Token

ClosureUseNode

Variable captured by a closure, optionally by reference. Rozšiřuje Node.

  • ampersand: ?Token
  • variable: Expression\VariableNode

ElseifNode

elseif branch, in either syntax. Rozšiřuje Node.

  • elseifKeyword: Token
  • openParen: Token
  • condition: ExpressionNode
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>

ElseNode

else branch, in either syntax; else if is an else with an if statement as the body. Rozšiřuje Node.

  • elseKeyword: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>

CaseNode

case or default of a switch; the separator is a colon or a semicolon. Rozšiřuje Node.

  • keyword: Token
  • value: ?ExpressionNode
  • separator: Token
  • statements: PlainNodeList<StatementNode>

CatchNode

catch clause with one or more types and an optional variable. Rozšiřuje Node.

  • catchKeyword: Token
  • openParen: Token
  • types: SeparatedNodeList<NameNode>
  • variable: ?Expression\VariableNode
  • closeParen: Token
  • body: Statement\BlockNode

FinallyNode

finally clause. Rozšiřuje Node.

  • finallyKeyword: Token
  • body: Statement\BlockNode

DeclareItemNode

Directive of a declare statement: strict_types=1. Rozšiřuje Node.

  • name: IdentifierNode
  • equals: Token
  • value: ExpressionNode

StaticVariableNode

Variable of a static statement with an optional initializer. Rozšiřuje Node.

  • variable: Expression\VariableNode
  • equals: ?Token
  • default: ?ExpressionNode

UseItemNode

Imported name with an optional alias; the type (function, const) appears only inside a group use. What the item imports is said by the statement it stands in, the prefix of a group included, so an item is not moved from one statement to another but written anew by UseNode::addImport(). Rozšiřuje Node.

  • kindKeyword: ?Token
  • name: NameNode
  • asKeyword: ?Token
  • alias: ?IdentifierNode
  • $symbolKind: SymbolKind – What the item imports: its own type where a group use writes one per item, else what the statement imports.
  • $fullName: string – The name the item imports, without a leading backslash: what is written here, and in a group use the prefix of the statement before it.
  • getStatement(): ?Statement\UseNode – The import the item belongs to; null for an item that is not in one.

ConstItemNode

Constant of a const statement or a class constant declaration. Rozšiřuje Node.

  • name: IdentifierNode
  • equals: Token
  • value: ExpressionNode

ListNode

Destructuring, written list(...) or [...]; the keyword is null for the short form. A short array is a literal until it stands where a place is assigned to, which is where it becomes one of these. It is no expression: it never carries a value. Rozšiřuje Node.

  • listKeyword: ?Token
  • openDelimiter: Token
  • items: SeparatedNodeList<ArrayItemNode|EmptyArrayItemNode>
  • closeDelimiter: Token

Příkazy

Deklarace a příkazy v PhpSyntax\Nodes\Statement: položky seznamu statements souboru, bloku, jmenného prostoru, větve case a alternativní syntaxe, a také tělo řídicí struktury (body).

NamespaceNode

namespace declaration; after namespace A; the following statements are nested in it. Rozšiřuje StatementNode.

  • namespaceKeyword: Token
  • name: ?NameNode
  • semicolon: ?Token
  • openBrace: ?Token
  • statements: PlainNodeList<StatementNode>
  • closeBrace: ?Token

UseNode

use import of classes, functions or constants, written item by item or as a group under a prefix (use A\{B, C};), which fills the slots the other form leaves empty. Rozšiřuje StatementNode.

  • useKeyword: Token
  • kindKeyword: ?Token
  • prefix: ?NameNode
  • namespaceSeparator: ?Token
  • openBrace: ?Token
  • items: SeparatedNodeList<UseItemNode>
  • closeBrace: ?Token
  • semicolon: Token
  • $symbolKind: SymbolKind – What the statement imports, which every item without a type of its own imports too.
  • isGroup(): bool – Whether the items are written as a group under a prefix, which every one of them imports.
  • addImport(string $name, ?string $alias = null, ?int $index = null): UseItemNode – Adds an import of the fully qualified name, written the way the statement writes its items: whole in a plain import, under the prefix in a group, which refuses a name standing outside it. The item imports what the statement imports and goes last unless an index says where.

ConstNode

const statement outside a class. Rozšiřuje StatementNode. Implementuje AttributeAwareNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • constKeyword: Token
  • items: SeparatedNodeList<ConstItemNode>
  • semicolon: Token

HaltCompilerNode

__halt_compiler(); the rest of the file is the data token. Rozšiřuje StatementNode.

  • haltCompilerKeyword: Token
  • openParen: Token
  • closeParen: Token
  • semicolon: Token
  • data: ?Token

InlineHtmlNode

Text outside PHP tags, including a BOM or a hashbang line. Rozšiřuje StatementNode.

  • html: Token
  • isPreamble(): bool – Whether the text is only what may precede the code of a pure PHP file: a byte order mark, a hashbang line, or both.

EmptyStatementNode

Bare semicolon, or a close tag after a terminated statement. Rozšiřuje StatementNode.

  • semicolon: Token

ExpressionStatementNode

Expression as a statement. Rozšiřuje StatementNode.

  • expression: ExpressionNode
  • semicolon: Token

BlockNode

Statements in braces. Rozšiřuje StatementNode.

  • openBrace: Token
  • statements: PlainNodeList<StatementNode>
  • closeBrace: Token

IfNode

if statement in either syntax; the body is a statement, the alternative syntax fills statements. Rozšiřuje StatementNode.

  • ifKeyword: Token
  • openParen: Token
  • condition: ExpressionNode
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>
  • elseifs: PlainNodeList<ElseifNode>
  • else: ?ElseNode
  • endKeyword: ?Token
  • semicolon: ?Token

WhileNode

while loop in either syntax. Rozšiřuje StatementNode.

  • whileKeyword: Token
  • openParen: Token
  • condition: ExpressionNode
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>
  • endKeyword: ?Token
  • semicolon: ?Token

DoWhileNode

do-while loop. Rozšiřuje StatementNode.

  • doKeyword: Token
  • body: StatementNode
  • whileKeyword: Token
  • openParen: Token
  • condition: ExpressionNode
  • closeParen: Token
  • semicolon: Token

ForNode

for loop in either syntax. Rozšiřuje StatementNode.

  • forKeyword: Token
  • openParen: Token
  • initializers: SeparatedNodeList<ExpressionNode>
  • firstSemicolon: Token
  • conditions: SeparatedNodeList<ExpressionNode>
  • secondSemicolon: Token
  • updates: SeparatedNodeList<ExpressionNode>
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>
  • endKeyword: ?Token
  • semicolon: ?Token

ForeachNode

foreach loop in either syntax. Rozšiřuje StatementNode.

  • foreachKeyword: Token
  • openParen: Token
  • expression: ExpressionNode
  • asKeyword: Token
  • key: ?ExpressionNode
  • doubleArrow: ?Token
  • ampersand: ?Token
  • value: ExpressionNode|ListNode
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>
  • endKeyword: ?Token
  • semicolon: ?Token

SwitchNode

switch statement in either syntax; a semicolon may precede the first case. Rozšiřuje StatementNode.

  • switchKeyword: Token
  • openParen: Token
  • subject: ExpressionNode
  • closeParen: Token
  • openBrace: ?Token
  • colon: ?Token
  • leadingSemicolon: ?Token
  • cases: PlainNodeList<CaseNode>
  • closeBrace: ?Token
  • endKeyword: ?Token
  • semicolon: ?Token

BreakNode

break with an optional level. Rozšiřuje StatementNode.

  • breakKeyword: Token
  • expression: ?ExpressionNode
  • semicolon: Token

ContinueNode

continue with an optional level. Rozšiřuje StatementNode.

  • continueKeyword: Token
  • expression: ?ExpressionNode
  • semicolon: Token

ReturnNode

return with an optional value. Rozšiřuje StatementNode.

  • returnKeyword: Token
  • expression: ?ExpressionNode
  • semicolon: Token

GlobalNode

global statement. Rozšiřuje StatementNode.

  • globalKeyword: Token
  • variables: SeparatedNodeList<ExpressionNode>
  • semicolon: Token

StaticNode

static variable declaration. Rozšiřuje StatementNode.

  • staticKeyword: Token
  • variables: SeparatedNodeList<StaticVariableNode>
  • semicolon: Token

EchoNode

echo statement; the keyword may be the <?= open tag and the semicolon a close tag. Rozšiřuje StatementNode.

  • echoKeyword: Token
  • expressions: SeparatedNodeList<ExpressionNode>
  • semicolon: Token

UnsetNode

unset statement. Rozšiřuje StatementNode.

  • unsetKeyword: Token
  • openParen: Token
  • variables: SeparatedNodeList<ExpressionNode>
  • closeParen: Token
  • semicolon: Token

DeclareNode

declare statement in its three forms: with a body, with a bare semicolon, or with the alternative syntax. Rozšiřuje StatementNode.

  • declareKeyword: Token
  • openParen: Token
  • items: SeparatedNodeList<DeclareItemNode>
  • closeParen: Token
  • body: ?StatementNode
  • colon: ?Token
  • statements: ?PlainNodeList<StatementNode>
  • endKeyword: ?Token
  • semicolon: ?Token

TryNode

try statement with catches and an optional finally. Rozšiřuje StatementNode.

  • tryKeyword: Token
  • body: Statement\BlockNode
  • catches: PlainNodeList<CatchNode>
  • finally: ?FinallyNode

GotoNode

goto statement. Rozšiřuje StatementNode.

  • gotoKeyword: Token
  • label: IdentifierNode
  • semicolon: Token

LabelNode

Label for goto. Rozšiřuje StatementNode.

  • name: IdentifierNode
  • colon: Token

FunctionNode

Function declaration. Rozšiřuje StatementNode. Implementuje AttributeAwareNode, FunctionLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • functionKeyword: Token
  • ampersand: ?Token
  • name: IdentifierNode
  • openParen: Token
  • parameters: SeparatedNodeList<ParameterNode>
  • closeParen: Token
  • colon: ?Token
  • returnType: ?TypeNode
  • body: Statement\BlockNode

ClassNode

Class declaration. Rozšiřuje StatementNode. Implementuje AttributeAwareNode, ClassLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • classKeyword: Token
  • name: IdentifierNode
  • extendsKeyword: ?Token
  • extends: ?NameNode
  • implementsKeyword: ?Token
  • implements: ?SeparatedNodeList<NameNode>
  • openBrace: Token
  • members: PlainNodeList<MemberNode>
  • closeBrace: Token

InterfaceNode

Interface declaration. Rozšiřuje StatementNode. Implementuje AttributeAwareNode, ClassLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • interfaceKeyword: Token
  • name: IdentifierNode
  • extendsKeyword: ?Token
  • extends: ?SeparatedNodeList<NameNode>
  • openBrace: Token
  • members: PlainNodeList<MemberNode>
  • closeBrace: Token

TraitNode

Trait declaration. Rozšiřuje StatementNode. Implementuje AttributeAwareNode, ClassLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • traitKeyword: Token
  • name: IdentifierNode
  • openBrace: Token
  • members: PlainNodeList<MemberNode>
  • closeBrace: Token

EnumNode

Enum declaration, optionally backed by a scalar type. Rozšiřuje StatementNode. Implementuje AttributeAwareNode, ClassLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • enumKeyword: Token
  • name: IdentifierNode
  • colon: ?Token
  • backingType: ?TypeNode
  • implementsKeyword: ?Token
  • implements: ?SeparatedNodeList<NameNode>
  • openBrace: Token
  • members: PlainNodeList<MemberNode>
  • closeBrace: Token

Výrazy

Výrazy v PhpSyntax\Nodes\Expression: operátory, volání, přístupy, přiřazení, closure a arrow funkce. Literály mají vlastní sekci Skaláry; destrukturace ListNode leží tady, ale výrazem není, protože stojí jen tam, kam se přiřazuje, a hodnotu nemá.

VariableNode

Variable: $a, $$a, ${expr}; inside a string also a bare name in ${name}. Rozšiřuje ExpressionNode.

  • dollar: ?Token
  • openBrace: ?Token
  • name: Token|ExpressionNode
  • closeBrace: ?Token
  • $plainName: ?string – The name without the dollar sign; null where the name is an expression ($$a, ${expr}).
  • isThis(): bool – Whether the variable is $this, the object a method runs on.

ArrayAccessNode

Array or string offset access: $a[$i], $a[]. Rozšiřuje ExpressionNode.

  • expression: ExpressionNode
  • openBracket: Token
  • index: ?ExpressionNode
  • closeBracket: Token

PropertyFetchNode

Property access with -> or ?->; the name may be an identifier, a variable or a braced expression. Rozšiřuje ExpressionNode.

  • object: ExpressionNode
  • operator: Token
  • openBrace: ?Token
  • name: IdentifierNode|ExpressionNode
  • closeBrace: ?Token
  • $plainName: ?string – The name of the property; null where the name is a variable or an expression ($a->$b, $a->{expr}).
  • isNullsafe(): bool – Whether the fetch is written with ?->, which skips it when the object is null.
  • isOfThis(): bool – Whether the property is one of $this, with either operator.

StaticPropertyFetchNode

Static property access: A::$b, A::$$b, A::${expr}. The name is written the way a variable is, dollar and braces included, but it names a property. Rozšiřuje ExpressionNode.

  • class: NameNode|ExpressionNode
  • doubleColon: Token
  • dollar: ?Token
  • openBrace: ?Token
  • name: Token|ExpressionNode
  • closeBrace: ?Token
  • $plainName: ?string – The name of the property without the dollar sign; null where the name is an expression ($$b, ${expr}).

ClassConstantFetchNode

Class constant access: A::B, A::class, A::{expr}. Rozšiřuje ExpressionNode.

  • class: NameNode|ExpressionNode
  • doubleColon: Token
  • openBrace: ?Token
  • name: IdentifierNode|ExpressionNode
  • closeBrace: ?Token

ConstantFetchNode

Constant access by name: FOO, \Foo\BAR. Rozšiřuje ExpressionNode.

  • name: NameNode

FunctionCallNode

Function call by name or on an expression. Rozšiřuje ExpressionNode.

  • name: NameNode|ExpressionNode
  • arguments: ArgumentListNode
  • static of(NameNode|ExpressionNode|string $name, ?ArgumentListNode $arguments = null): Expression\FunctionCallNode – A call of the name, written as a node or as text, or of the expression, in parentheses where the call would take it for something else.

MethodCallNode

Method call with -> or ?->. Rozšiřuje ExpressionNode.

  • object: ExpressionNode
  • operator: Token
  • openBrace: ?Token
  • name: IdentifierNode|ExpressionNode
  • closeBrace: ?Token
  • arguments: ArgumentListNode
  • static of(ExpressionNode $object, string $name, ?ArgumentListNode $arguments = null, bool $nullsafe = false): Expression\MethodCallNode – A call of the method on the object, in parentheses where it could not be reached into bare.
  • isNullsafe(): bool – Whether the call is written with ?->, which skips it when the object is null.

StaticMethodCallNode

Static method call: A::b(), $a::b(), A::{expr}(). Rozšiřuje ExpressionNode.

  • class: NameNode|ExpressionNode
  • doubleColon: Token
  • openBrace: ?Token
  • name: IdentifierNode|ExpressionNode
  • closeBrace: ?Token
  • arguments: ArgumentListNode
  • static of(NameNode|ExpressionNode $class, string $name, ?ArgumentListNode $arguments = null): Expression\StaticMethodCallNode – A call of the static method of the class, an expression in parentheses where :: could not follow it bare.

NewNode

Instantiation of a named, dynamic or anonymous class. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • newKeyword: Token
  • class: NameNode|ExpressionNode|AnonymousClassNode
  • arguments: ?ArgumentListNode
  • static of(NameNode|ExpressionNode $class, ?ArgumentListNode $arguments = null): Expression\NewNode – An instantiation of the class, an expression in parentheses where it could not name one bare; no list is written where none is given.

ArrayNode

Array literal in either syntax: [...] or array(...). A short array standing where a place is assigned to destructures instead, and is a ListNode. Rozšiřuje ExpressionNode.

  • arrayKeyword: ?Token
  • openDelimiter: Token
  • items: SeparatedNodeList<ArrayItemNode|EmptyArrayItemNode>
  • closeDelimiter: Token

AssignmentNode

Assignment $a = $b. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • target: ExpressionNode|ListNode
  • equals: Token
  • expression: ExpressionNode
  • static of(ExpressionNode|ListNode $target, ExpressionNode $expression): Expression\AssignmentNode – The assignment of the expression to the target, a short array written as the target destructuring as it does in the code, and the expression in parentheses where it binds looser than the assignment takes. Throws InvalidArgumentException for a target nothing can be assigned to.

CombinedAssignmentNode

Combined assignment $a += $b, whose operator token tells which operation is baked into it. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • target: ExpressionNode
  • operator: Token
  • expression: ExpressionNode
  • static of(ExpressionNode $target, string $operator, ExpressionNode $expression): Expression\CombinedAssignmentNode – The combined assignment of the expression to the target, the expression in parentheses where it binds looser than the assignment takes. Throws InvalidArgumentException for what is no combined assignment operator, and for a target nothing can be assigned to.
  • replaceOperator(string $operator): void – Replaces the operator by another combined assignment one, the trivia around it staying; every one binds alike, so no parentheses change. Throws InvalidArgumentException for what is no combined assignment operator.

AssignmentByReferenceNode

Assignment by reference $a = &$b; the grammar takes a variable or a new expression on the right. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • target: ExpressionNode
  • equals: Token
  • ampersand: Token
  • expression: ExpressionNode

BinaryOpNode

Binary operation; the operator token tells which (arithmetic, comparison, logical, bitwise, concatenation, coalesce, pipe). Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • left: ExpressionNode
  • operator: Token
  • right: ExpressionNode
  • static of(ExpressionNode $left, string $operator, ExpressionNode $right): Expression\BinaryOpNode – The operation on the two operands, each in parentheses where it binds looser than its side of the operator takes. Throws InvalidArgumentException for what is no binary operator.
  • replaceOperator(string $operator): void – Replaces the operator by another binary one, the trivia around it staying, and puts the operands and the operation itself in parentheses where the new precedence asks, taking away those it makes needless. Throws InvalidArgumentException for what is no binary operator.
  • isLogical(): bool – Whether the operator is &&, ||, and, or or xor, the operators the parts of a condition are chained with.

UnaryOpNode

Unary operation written before its operand: +, -, !, ~, @; ++ and -- are a PrefixOpNode, the way the grammar tells them apart. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • operator: Token
  • expression: ExpressionNode
  • replaceOperator(string $operator): void – Replaces the operator by another unary one, the trivia around it staying, and puts the operand and the operation itself in parentheses where the new precedence asks, ! binding looser than the rest. Throws InvalidArgumentException for what is no unary operator.

PrefixOpNode

Prefix increment or decrement. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • operator: Token
  • target: ExpressionNode

PostfixOpNode

Postfix increment or decrement. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • target: ExpressionNode
  • operator: Token

CastNode

Type cast; the cast token keeps its spelling including inner whitespace: ( int ). Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • operator: Token
  • expression: ExpressionNode
  • $type: string – The type the cast converts to, in the name PHP knows it by: (integer) is int, (double) and (real) are float.
  • replaceOperator(string $operator): void – Replaces the cast by another one, (int) by (string) for instance, the trivia around it staying; every cast binds alike, so no parentheses change. Another spelling of the same cast is setText() of the operator. Throws InvalidArgumentException for what is no cast.

TernaryNode

Ternary conditional $a ? $b : $c, or the elvis form $a ?: $c leaving then empty. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • condition: ExpressionNode
  • question: Token
  • then: ?ExpressionNode
  • colon: Token
  • else: ExpressionNode

InstanceofNode

instanceof check against a name or a dynamic class. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • expression: ExpressionNode
  • instanceofKeyword: Token
  • class: NameNode|ExpressionNode

ParenthesizedNode

Expression in parentheses. Rozšiřuje ExpressionNode.

  • openParen: Token
  • expression: ExpressionNode
  • closeParen: Token
  • static of(ExpressionNode $expression): Expression\ParenthesizedNode – The expression in parentheses, without the trivia on its edges.
  • isRedundant(): bool – Whether the parentheses may go without the code coming to mean anything else: what stands in them binds at least as tightly as the place they stand in asks, and what reaches into them could reach into it bare. Where the answer is not certain it is no.

IssetNode

isset(...) with one or more variables. Rozšiřuje ExpressionNode.

  • issetKeyword: Token
  • openParen: Token
  • variables: SeparatedNodeList<ExpressionNode>
  • closeParen: Token

EmptyNode

empty(...). Rozšiřuje ExpressionNode.

  • emptyKeyword: Token
  • openParen: Token
  • expression: ExpressionNode
  • closeParen: Token

EvalNode

eval(...). Rozšiřuje ExpressionNode.

  • evalKeyword: Token
  • openParen: Token
  • expression: ExpressionNode
  • closeParen: Token

IncludeNode

include, include_once, require or require_once; the keyword token tells which. Rozšiřuje ExpressionNode. Implementuje RightExtendingNode, OperatorNode.

  • includeKeyword: Token
  • expression: ExpressionNode

ExitNode

exit or die with optional arguments. Rozšiřuje ExpressionNode.

  • exitKeyword: Token
  • arguments: ?ArgumentListNode

PrintNode

print expression. Rozšiřuje ExpressionNode. Implementuje RightExtendingNode, OperatorNode.

  • printKeyword: Token
  • expression: ExpressionNode

YieldNode

yield, yield $value or yield $key => $value. Rozšiřuje ExpressionNode. Implementuje RightExtendingNode, OperatorNode.

  • yieldKeyword: Token
  • key: ?ExpressionNode
  • doubleArrow: ?Token
  • value: ?ExpressionNode

YieldFromNode

yield from expression. Rozšiřuje ExpressionNode. Implementuje RightExtendingNode, OperatorNode.

  • yieldFromKeyword: Token
  • expression: ExpressionNode

ThrowNode

throw expression. Rozšiřuje ExpressionNode. Implementuje RightExtendingNode, OperatorNode.

  • throwKeyword: Token
  • expression: ExpressionNode

CloneNode

clone expression; clone(...) with arguments is a function call. Rozšiřuje ExpressionNode. Implementuje OperatorNode.

  • cloneKeyword: Token
  • expression: ExpressionNode

MatchNode

match expression. Rozšiřuje ExpressionNode.

  • matchKeyword: Token
  • openParen: Token
  • subject: ExpressionNode
  • closeParen: Token
  • openBrace: Token
  • arms: SeparatedNodeList<MatchArmNode>
  • closeBrace: Token

ClosureNode

Anonymous function, optionally static, with captured variables. Rozšiřuje ExpressionNode. Implementuje AttributeAwareNode, FunctionLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • staticKeyword: ?Token
  • functionKeyword: Token
  • ampersand: ?Token
  • openParen: Token
  • parameters: SeparatedNodeList<ParameterNode>
  • closeParen: Token
  • uses: ?ClosureUsesNode
  • colon: ?Token
  • returnType: ?TypeNode
  • body: Statement\BlockNode
  • getCapturedVariableNames(): list<string> – Names of the variables the closure captures with use (...), with the dollar sign.

ArrowFunctionNode

Arrow function fn(...) => expr, optionally static. Rozšiřuje ExpressionNode. Implementuje AttributeAwareNode, FunctionLikeNode, RightExtendingNode, OperatorNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • staticKeyword: ?Token
  • fnKeyword: Token
  • ampersand: ?Token
  • openParen: Token
  • parameters: SeparatedNodeList<ParameterNode>
  • closeParen: Token
  • colon: ?Token
  • returnType: ?TypeNode
  • doubleArrow: Token
  • expression: ExpressionNode

ShellExecNode

Command in backticks with interpolation. Rozšiřuje ExpressionNode.

  • openBacktick: Token
  • parts: PlainNodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>
  • closeBacktick: Token

Členy tříd

Vlastnosti, konstanty, metody, případy výčtu, hooky a použití traitů v PhpSyntax\Nodes\Member.

PropertyNode

Property declaration; one or more properties, optionally with hooks. Rozšiřuje MemberNode. Implementuje AttributeAwareNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • type: ?TypeNode
  • items: SeparatedNodeList<Member\PropertyItemNode>
  • semicolon: ?Token
  • openBrace: ?Token
  • hooks: ?PlainNodeList<Member\PropertyHookNode>
  • closeBrace: ?Token

PropertyItemNode

One property of a declaration with an optional default. Rozšiřuje Node.

  • variable: Token
  • equals: ?Token
  • default: ?ExpressionNode
  • $plainName: string – The name of the property without the dollar sign.

PropertyHookNode

Property hook (get, set) with a block body, an arrow body or none. Rozšiřuje Node. Implementuje AttributeAwareNode, FunctionLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • ampersand: ?Token
  • name: IdentifierNode
  • openParen: ?Token
  • parameters: ?SeparatedNodeList<ParameterNode>
  • closeParen: ?Token
  • body: ?Statement\BlockNode
  • doubleArrow: ?Token
  • expression: ?ExpressionNode
  • semicolon: ?Token
  • $returnType: ?TypeNode

ClassConstNode

Class constant declaration, optionally typed. Rozšiřuje MemberNode. Implementuje AttributeAwareNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • constKeyword: Token
  • type: ?TypeNode
  • items: SeparatedNodeList<ConstItemNode>
  • semicolon: Token

MethodNode

Method declaration; abstract and interface methods end with a semicolon instead of a body. Rozšiřuje MemberNode. Implementuje AttributeAwareNode, FunctionLikeNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • modifiers: ModifiersNode
  • functionKeyword: Token
  • ampersand: ?Token
  • name: IdentifierNode
  • openParen: Token
  • parameters: SeparatedNodeList<ParameterNode>
  • closeParen: Token
  • colon: ?Token
  • returnType: ?TypeNode
  • body: ?Statement\BlockNode
  • semicolon: ?Token
  • isConstructor(): bool – Whether the method is the constructor, whose name PHP compares without regard to letter case.

TraitUseNode

use of traits with optional adaptations in braces. Rozšiřuje MemberNode.

  • useKeyword: Token
  • traits: SeparatedNodeList<NameNode>
  • semicolon: ?Token
  • openBrace: ?Token
  • adaptations: ?PlainNodeList<Member\TraitAdaptationNode>
  • closeBrace: ?Token

TraitPrecedenceNode

Trait adaptation A::m insteadof B. Rozšiřuje Member\TraitAdaptationNode.

  • trait: NameNode
  • doubleColon: Token
  • method: IdentifierNode
  • insteadofKeyword: Token
  • traits: SeparatedNodeList<NameNode>
  • semicolon: Token

TraitAliasNode

Trait adaptation m as [modifier] [alias]. Rozšiřuje Member\TraitAdaptationNode.

  • trait: ?NameNode
  • doubleColon: ?Token
  • method: IdentifierNode
  • asKeyword: Token
  • modifier: ?Token
  • alias: ?IdentifierNode
  • semicolon: Token

EnumCaseNode

Enum case with an optional backing value. Rozšiřuje MemberNode. Implementuje AttributeAwareNode.

  • attributes: PlainNodeList<AttributeGroupNode>
  • caseKeyword: Token
  • name: IdentifierNode
  • equals: ?Token
  • value: ?ExpressionNode
  • semicolon: Token

Skaláry

Čísla, řetězce a jejich interpolace, true, false, null a magické konstanty v PhpSyntax\Nodes\Scalar; text zůstává tak, jak byl zapsán.

IntegerNode

Integer literal in any base, kept as written. Rozšiřuje ScalarNode.

  • token: Token
  • $base: int – The base the literal is written in: 2, 8, 10 or 16; a leading zero alone is the old octal notation.
  • $value: int – The value of the literal; a literal beyond the integer range is a float to PHP, so it is a FloatNode.

FloatNode

Literal PHP reads as a float, kept as written. That is not the same as float syntax: an integer literal beyond the integer range is a float to PHP whatever its base (0xFFFFFFFFFFFFFFFF as much as 9223372036854775808), and the lexer hands it over as one, so such a literal is a node of this class. Rozšiřuje ScalarNode.

  • token: Token
  • $value: float – The value of the literal, which is also how an integer literal beyond the integer range reaches PHP.

BooleanNode

Boolean literal, kept in the letter case and with the leading backslash it is written with: true, FALSE, \True. Rozšiřuje ScalarNode.

  • token: Token
  • $value: bool

NullNode

Null literal, kept in the letter case and with the leading backslash it is written with: null, NULL, \Null. Rozšiřuje ScalarNode.

  • token: Token

StringNode

String literal without interpolation, quotes included. Rozšiřuje ScalarNode.

  • token: Token
  • $quote: string – The delimiter the literal is written with: ' or ", a b or B prefix left out.
  • $value: string – The value of the literal with its escape sequences resolved.
  • static fromValue(string $value, string $quote = "'"): Scalar\StringNode – A literal standing for the value, escaped as the delimiter needs it.
  • setValue(string $value, ?string $quote = null): static – Writes the literal: the value escaped as the delimiter needs it, in the delimiter given or in the one it has. The two go together, because the delimiter decides how the value is written.

UnquotedStringNode

Name of an offset written without quotes inside an interpolated string ("$row[label]"), which PHP reads as a string; having no delimiter, it stands for itself and holds no escape sequence. Rozšiřuje ScalarNode.

  • token: Token
  • $value: string – The value of the offset, which is the text as it stands.

MagicConstantNode

Magic constant: __LINE__, __FILE__, __DIR__, __CLASS__, __TRAIT__, __METHOD__, __FUNCTION__, __PROPERTY__, __NAMESPACE__. Rozšiřuje ScalarNode.

  • token: Token

InterpolatedStringNode

Double-quoted string with interpolated variables or expressions. Rozšiřuje ScalarNode.

  • openQuote: Token
  • parts: PlainNodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>
  • closeQuote: Token

HeredocNode

Heredoc or nowdoc; the closing delimiter keeps its indentation, the parts keep theirs. Rozšiřuje ScalarNode.

  • openDelimiter: Token
  • parts: PlainNodeList<Scalar\InterpolatedStringPartNode|Scalar\InterpolationNode|ExpressionNode>
  • closeDelimiter: Token
  • $label: string – The label between <<< and the body, without quotes.
  • $indentation: string – The indentation of the closing delimiter, which the body shares.
  • $value: string – The text of the body with its escape sequences resolved and the common indentation removed. Throws LogicException when the heredoc interpolates; hasInterpolation() tells beforehand.
  • isNowdoc(): bool – Whether the label is in single quotes, which makes a nowdoc that resolves no escape sequences.
  • hasInterpolation(): bool – Whether any part of the body is an interpolation, which leaves the heredoc without a value of its own.

InterpolatedStringPartNode

Literal text between interpolations, whitespace included. What its escape sequences mean depends on the string it stands in, so the part keeps them as written and whoever reads it resolves them for that string, as HeredocNode::$value does for a heredoc. Rozšiřuje Node.

  • token: Token

InterpolationNode

Braced interpolation inside a string: {$expr}, ${name}, ${name[expr]} or ${expr}. Rozšiřuje Node.

  • openBrace: Token
  • expression: ExpressionNode
  • closeBrace: Token

Typy

Typové deklarace parametrů, vlastností, konstant třídy a návratových hodnot a typ hodnot výčtu (enum Suit: string) v PhpSyntax\Nodes\Type.

NamedTypeNode

Type given by a name: builtin (int, static, array, callable) or a class. Rozšiřuje TypeNode.

  • name: NameNode
  • isBuiltin(): bool – Whether the type is one PHP knows itself, self, static and parent among them.

NullableTypeNode

Nullable type: ?T. Rozšiřuje TypeNode.

  • question: Token
  • type: TypeNode

UnionTypeNode

Union type A|B; a member may be a parenthesized intersection (DNF). Rozšiřuje TypeNode.

  • types: SeparatedNodeList<TypeNode>

IntersectionTypeNode

Intersection type A&B, parenthesized inside a union. Rozšiřuje TypeNode.

  • openParen: ?Token
  • types: SeparatedNodeList<TypeNode>
  • closeParen: ?Token