Expand description
Owned (lifetime-free) versions of all AST types.
Arena-allocated types (Program<'arena, 'src>, etc.) cannot be stored in a
struct alongside the bumpalo::Bump arena that owns them — the borrow checker
rejects the self-referential pattern. These owned mirrors solve that: they use
Box<str> instead of &str, Box<[T]> instead of ArenaVec<'arena, T>, and
Box<T> instead of &'arena T. The result is 'static — no lifetime
parameters, storeable in a HashMap, sendable across threads.
Serialization is byte-for-byte identical to the arena types so existing JSON snapshots remain valid.
§Entry points
Call php_rs_parser::parse() — it returns a php_rs_parser::ParseResult
whose .program field is an owned Program. To convert an
arena-allocated Program directly, use
to_owned_program.
Re-exports§
pub use fold::fold_owned_arg;pub use fold::fold_owned_attribute;pub use fold::fold_owned_catch_clause;pub use fold::fold_owned_class_member;pub use fold::fold_owned_closure_use_var;pub use fold::fold_owned_enum_member;pub use fold::fold_owned_expr;pub use fold::fold_owned_match_arm;pub use fold::fold_owned_name;pub use fold::fold_owned_param;pub use fold::fold_owned_program;pub use fold::fold_owned_property_hook;pub use fold::fold_owned_stmt;pub use fold::fold_owned_type_hint;pub use fold::FoldOwned;pub use visitor::walk_owned_arg;pub use visitor::walk_owned_attribute;pub use visitor::walk_owned_catch_clause;pub use visitor::walk_owned_class_member;pub use visitor::walk_owned_comments;pub use visitor::walk_owned_enum_member;pub use visitor::walk_owned_expr;pub use visitor::walk_owned_match_arm;pub use visitor::walk_owned_name;pub use visitor::walk_owned_param;pub use visitor::walk_owned_program;pub use visitor::walk_owned_property_hook;pub use visitor::walk_owned_stmt;pub use visitor::walk_owned_trait_use;pub use visitor::walk_owned_type_hint;pub use visitor::OwnedScope;pub use visitor::OwnedScopeVisitor;pub use visitor::OwnedScopeWalker;pub use visitor::OwnedVisitor;
Modules§
- fold
- Owned AST transformation via the
FoldOwnedtrait. - visitor
- Visitor infrastructure for owned (lifetime-free) PHP AST traversal.
Structs§
- Arg
- A call argument.
- Array
Access Expr - An array offset access.
- Array
Element - An element of an array literal.
- Arrow
Function Expr - An
fnarrow function. - Assign
Expr - An assignment.
- Attribute
- A
#[...]attribute. - Binary
Expr - A binary operation.
- Block
- Owned mirror of
crate::ast::Block— a brace-delimited statement block. - Callable
Create Expr - A first-class callable, e.g.
f(...). - Catch
Clause - A
catchclause. - Class
Body - The braced member list of a class-like declaration.
- Class
Const Decl - A class constant declaration.
- Class
Decl - A class declaration.
- Class
Member - A member of a class-like body.
- Closure
Expr - An anonymous function.
- Closure
UseVar - A variable captured by a closure
useclause. - Comment
- A source comment.
- Const
Item - One item of a top-level
conststatement. - Declare
Stmt - A
declare(...)statement. - DoWhile
Stmt - A
do ... whileloop. - Else
IfBranch - An
elseifbranch. - Enum
Body - The braced member list of an enum.
- Enum
Case - An enum
case. - Enum
Decl - An enum declaration.
- Enum
Member - A member of an enum body.
- Expr
- An expression.
- ForStmt
- A
forloop. - Foreach
Stmt - A
foreachloop. - Function
Call Expr - A function call.
- Function
Decl - A function declaration.
- IfStmt
- An
ifstatement. - Interface
Decl - An interface declaration.
- Match
Arm - An arm of a
matchexpression. - Match
Expr - A
matchexpression. - Method
Call Expr - A
->or?->method call. - Method
Decl - A method declaration.
- Name
- A possibly qualified PHP name.
- Namespace
Decl - A
namespacedeclaration. - NewExpr
- A
newexpression. - Null
Coalesce Expr - A
??expression. - Param
- A function or method parameter.
- Program
- Root of a parsed file.
- Property
Access Expr - A
->or?->property access. - Property
Decl - A property declaration.
- Property
Hook - A property
getorsethook. - Static
Access Expr - A
::static property or constant access. - Static
DynMethod Call Expr - A static call with a dynamic method expression.
- Static
Method Call Expr - A
Class::method()call. - Static
Var - One variable of a
staticstatement. - Stmt
- A statement.
- Switch
Body - The braced body of a
switch. - Switch
Case - A
caseordefaultarm. - Switch
Stmt - A
switchstatement. - Ternary
Expr - A ternary or short-ternary conditional.
- Trait
Adaptation - A
insteadoforasrule in a trait use. - Trait
Decl - A trait declaration.
- Trait
UseDecl - A
use Trait;clause inside a class. - TryCatch
Stmt - A
trystatement. - Type
Hint - A type declaration.
- Unary
Postfix Expr - A postfix unary operation.
- Unary
Prefix Expr - A prefix unary operation.
- UseDecl
- A
useimport declaration. - UseItem
- One imported name in a
usedeclaration. - While
Stmt - A
whileloop. - Yield
Expr - A
yieldoryield fromexpression.
Enums§
- Callable
Create Kind - The callee of a first-class callable.
- Class
Member Kind - The kind of a class member.
- Enum
Member Kind - The kind of an enum member.
- Expr
Kind - The kind of an expression.
- Namespace
Body - Whether a namespace is braced or statement-terminated.
- Property
Hook Body - The body of a property hook.
- Stmt
Kind - The kind of a statement.
- String
Part - A segment of an interpolated string.
- Trait
Adaptation Kind - The kind of trait adaptation rule.
- Type
Hint Kind - The shape of a type declaration.
Functions§
- from_
owned_ program - Convert an owned
Programinto an arena-allocatedProgram. - to_
owned_ expr - Convert an arena-allocated
Exprinto anExpr. - to_
owned_ name - Convert an arena-allocated
Nameinto aName. - to_
owned_ program - Convert an arena-allocated
Programinto aProgram. - to_
owned_ stmt - Convert an arena-allocated
Stmtinto aStmt. - to_
owned_ type_ hint - Convert an arena-allocated
TypeHintinto aTypeHint.