Expand description
Arena-allocated AST node types.
Structs§
- Arena
Vec - Arena-allocated Vec. Thin newtype over bumpalo::collections::Vec that implements Serialize and Debug.
- Arg
- A call argument, including named, spread and by-reference forms.
- Array
Access Expr - An array index access:
$a[i]. - Array
Element - An element of an array literal.
- Arrow
Function Expr - An arrow function:
fn($x) => expr. - Assign
Expr - An assignment expression.
- Attribute
- A single attribute:
#[Name(args)]. - Binary
Expr - A binary operation.
- Block
- A brace-delimited statement block. Used both as a standalone block
statement (
StmtKind::Block) and as the body of constructs that are always braced (functions, methods, closures,try/catch/finally, braced namespaces, property-hook blocks) — those positions hold a&Blockso the “it’s a block” invariant is enforced by the type. - Callable
Create Expr - A first-class callable expression.
- Catch
Clause - A
catch (Type $e) { ... }clause. - Class
Body - The braced member list of a class-like declaration.
- Class
Const Decl - A class constant:
const X = 1;. - Class
Decl - A class declaration, or the body of an anonymous class.
- Class
Member - A member of a class, interface or trait body.
- Class
Modifiers - Modifiers preceding
class. - Closure
Expr - A closure:
function() use ($x) { ... }. - Closure
UseVar - A variable captured in a closure
uselist. - Comment
- A comment found in the source file.
- Const
Item - One
NAME = valueitem of a top-levelconststatement. - Declare
Stmt - A
declare(...)statement. - DoWhile
Stmt - A
do ... whileloop. - Else
IfBranch - An
elseif(orelse if) branch. - Enum
Body - The braced member list of an enum.
- Enum
Case - A
caseinside an enum. - Enum
Decl - An enum declaration (PHP 8.1+).
- Enum
Member - A member of an enum body.
- Expr
- An expression node.
- ForStmt
- A
forloop. - Foreach
Stmt - A
foreachloop. - Function
Call Expr - A function call:
name(args). - Function
Decl - A named function declaration:
function foo() {}. - Ident
- A bare identifier — the kind that names a function, class, parameter,
enum case, etc. Distinct from
Name, which represents possibly-qualified names. - IfStmt
- An
ifstatement with optionalelseif/elsebranches. - Interface
Decl - An interface declaration.
- Match
Arm - One arm of a
match. - Match
Expr - A
matchexpression. - Method
Call Expr - A method call:
$obj->method(args). - Method
Decl - A method declaration inside a class-like body.
- NameStr
- A name string from either the source buffer or the bump arena. Use
as_strorDerefto get the string value — the allocation origin is an internal parser detail. - Namespace
Decl - A
namespacedeclaration. - NewExpr
- An instantiation:
new Foo(args). - Null
Coalesce Expr - A
??expression. - Param
- A function, method, closure or hook parameter.
- Program
- The root AST node representing a complete PHP file.
- Property
Access Expr - A property access:
$obj->prop. - Property
Decl - A property declaration:
public int $x = 0;. - Property
Hook - A property hook:
get { ... }orset => ...(PHP 8.4+). - Static
Access Expr - A static member access:
Class::$proporClass::CONST. - Static
DynMethod Call Expr - A static call with a dynamic method name:
Class::$method(args). - Static
Method Call Expr - A static method call:
Class::method(args). - Static
Var - One variable of a
static $x = 1;statement. - Stmt
- A statement node.
- Switch
Body - The case list of a
switch. - Switch
Case - A
caseordefaultclause. - Switch
Stmt - A
switchstatement. - Ternary
Expr - A ternary
?:expression. - Trait
Adaptation - A single rule in a trait
useadaptation block. - Trait
Decl - A trait declaration.
- Trait
UseDecl - A
useof traits inside a class-like body. - TryCatch
Stmt - A
trystatement withcatchandfinallyclauses. - Type
Hint - A type declaration with its source range.
- Unary
Postfix Expr - A postfix unary operation.
- Unary
Prefix Expr - A prefix unary operation.
- UseDecl
- A
useimport statement. - UseItem
- One imported name in a
usestatement. - While
Stmt - A
whileloop. - Yield
Expr - A
yieldoryield fromexpression.
Enums§
- Assign
Op - Assignment operators.
- Binary
Op - Binary operators.
- Builtin
Type - PHP built-in type keyword — zero-cost alternative to
Name::Simplefor the 20 reserved type names. One byte instead of aCow<str>+Spanin the AST. - Callable
Create Kind - The callee forms of a first-class callable.
- Cast
Kind - The type of a cast expression.
- Class
Member Kind - The kinds of class-like member.
- Comment
Kind - Distinguishes the four syntactic forms of PHP comment.
- Enum
Member Kind - The kinds of enum member.
- Expr
Kind - The kinds of expression.
- Include
Kind - The include/require keyword used.
- Magic
Const Kind - The magic constants.
- Name
- A PHP name (identifier, qualified name, fully-qualified name, or relative name).
- Name
Kind - How a name is qualified.
- Namespace
Body - Whether a namespace is braced or simple.
- Property
Hook Body - The body form of a property hook.
- Property
Hook Kind - Which accessor a property hook implements.
- Stmt
Kind - The kinds of statement.
- String
Part - A segment of an interpolated string.
- Trait
Adaptation Kind - The kinds of trait adaptation rule.
- Type
Hint Kind - A PHP type hint.
- Unary
Postfix Op - Postfix unary operators.
- Unary
Prefix Op - Prefix unary operators.
- UseKind
- What a
useimport brings in. - Visibility
- Member visibility modifier.