Skip to main content

Module ast

Module ast 

Source
Expand description

Arena-allocated AST node types.

Structs§

ArenaVec
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.
ArrayAccessExpr
An array index access: $a[i].
ArrayElement
An element of an array literal.
ArrowFunctionExpr
An arrow function: fn($x) => expr.
AssignExpr
An assignment expression.
Attribute
A single attribute: #[Name(args)].
BinaryExpr
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 &Block so the “it’s a block” invariant is enforced by the type.
CallableCreateExpr
A first-class callable expression.
CatchClause
A catch (Type $e) { ... } clause.
ClassBody
The braced member list of a class-like declaration.
ClassConstDecl
A class constant: const X = 1;.
ClassDecl
A class declaration, or the body of an anonymous class.
ClassMember
A member of a class, interface or trait body.
ClassModifiers
Modifiers preceding class.
ClosureExpr
A closure: function() use ($x) { ... }.
ClosureUseVar
A variable captured in a closure use list.
Comment
A comment found in the source file.
ConstItem
One NAME = value item of a top-level const statement.
DeclareStmt
A declare(...) statement.
DoWhileStmt
A do ... while loop.
ElseIfBranch
An elseif (or else if) branch.
EnumBody
The braced member list of an enum.
EnumCase
A case inside an enum.
EnumDecl
An enum declaration (PHP 8.1+).
EnumMember
A member of an enum body.
Expr
An expression node.
ForStmt
A for loop.
ForeachStmt
A foreach loop.
FunctionCallExpr
A function call: name(args).
FunctionDecl
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 if statement with optional elseif/else branches.
InterfaceDecl
An interface declaration.
MatchArm
One arm of a match.
MatchExpr
A match expression.
MethodCallExpr
A method call: $obj->method(args).
MethodDecl
A method declaration inside a class-like body.
NameStr
A name string from either the source buffer or the bump arena. Use as_str or Deref to get the string value — the allocation origin is an internal parser detail.
NamespaceDecl
A namespace declaration.
NewExpr
An instantiation: new Foo(args).
NullCoalesceExpr
A ?? expression.
Param
A function, method, closure or hook parameter.
Program
The root AST node representing a complete PHP file.
PropertyAccessExpr
A property access: $obj->prop.
PropertyDecl
A property declaration: public int $x = 0;.
PropertyHook
A property hook: get { ... } or set => ... (PHP 8.4+).
StaticAccessExpr
A static member access: Class::$prop or Class::CONST.
StaticDynMethodCallExpr
A static call with a dynamic method name: Class::$method(args).
StaticMethodCallExpr
A static method call: Class::method(args).
StaticVar
One variable of a static $x = 1; statement.
Stmt
A statement node.
SwitchBody
The case list of a switch.
SwitchCase
A case or default clause.
SwitchStmt
A switch statement.
TernaryExpr
A ternary ?: expression.
TraitAdaptation
A single rule in a trait use adaptation block.
TraitDecl
A trait declaration.
TraitUseDecl
A use of traits inside a class-like body.
TryCatchStmt
A try statement with catch and finally clauses.
TypeHint
A type declaration with its source range.
UnaryPostfixExpr
A postfix unary operation.
UnaryPrefixExpr
A prefix unary operation.
UseDecl
A use import statement.
UseItem
One imported name in a use statement.
WhileStmt
A while loop.
YieldExpr
A yield or yield from expression.

Enums§

AssignOp
Assignment operators.
BinaryOp
Binary operators.
BuiltinType
PHP built-in type keyword — zero-cost alternative to Name::Simple for the 20 reserved type names. One byte instead of a Cow<str> + Span in the AST.
CallableCreateKind
The callee forms of a first-class callable.
CastKind
The type of a cast expression.
ClassMemberKind
The kinds of class-like member.
CommentKind
Distinguishes the four syntactic forms of PHP comment.
EnumMemberKind
The kinds of enum member.
ExprKind
The kinds of expression.
IncludeKind
The include/require keyword used.
MagicConstKind
The magic constants.
Name
A PHP name (identifier, qualified name, fully-qualified name, or relative name).
NameKind
How a name is qualified.
NamespaceBody
Whether a namespace is braced or simple.
PropertyHookBody
The body form of a property hook.
PropertyHookKind
Which accessor a property hook implements.
StmtKind
The kinds of statement.
StringPart
A segment of an interpolated string.
TraitAdaptationKind
The kinds of trait adaptation rule.
TypeHintKind
A PHP type hint.
UnaryPostfixOp
Postfix unary operators.
UnaryPrefixOp
Prefix unary operators.
UseKind
What a use import brings in.
Visibility
Member visibility modifier.