Skip to main content

Module owned

Module owned 

Source
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 FoldOwned trait.
visitor
Visitor infrastructure for owned (lifetime-free) PHP AST traversal.

Structs§

Arg
A call argument.
ArrayAccessExpr
An array offset access.
ArrayElement
An element of an array literal.
ArrowFunctionExpr
An fn arrow function.
AssignExpr
An assignment.
Attribute
A #[...] attribute.
BinaryExpr
A binary operation.
Block
Owned mirror of crate::ast::Block — a brace-delimited statement block.
CallableCreateExpr
A first-class callable, e.g. f(...).
CatchClause
A catch clause.
ClassBody
The braced member list of a class-like declaration.
ClassConstDecl
A class constant declaration.
ClassDecl
A class declaration.
ClassMember
A member of a class-like body.
ClosureExpr
An anonymous function.
ClosureUseVar
A variable captured by a closure use clause.
Comment
A source comment.
ConstItem
One item of a top-level const statement.
DeclareStmt
A declare(...) statement.
DoWhileStmt
A do ... while loop.
ElseIfBranch
An elseif branch.
EnumBody
The braced member list of an enum.
EnumCase
An enum case.
EnumDecl
An enum declaration.
EnumMember
A member of an enum body.
Expr
An expression.
ForStmt
A for loop.
ForeachStmt
A foreach loop.
FunctionCallExpr
A function call.
FunctionDecl
A function declaration.
IfStmt
An if statement.
InterfaceDecl
An interface declaration.
MatchArm
An arm of a match expression.
MatchExpr
A match expression.
MethodCallExpr
A -> or ?-> method call.
MethodDecl
A method declaration.
Name
A possibly qualified PHP name.
NamespaceDecl
A namespace declaration.
NewExpr
A new expression.
NullCoalesceExpr
A ?? expression.
Param
A function or method parameter.
Program
Root of a parsed file.
PropertyAccessExpr
A -> or ?-> property access.
PropertyDecl
A property declaration.
PropertyHook
A property get or set hook.
StaticAccessExpr
A :: static property or constant access.
StaticDynMethodCallExpr
A static call with a dynamic method expression.
StaticMethodCallExpr
A Class::method() call.
StaticVar
One variable of a static statement.
Stmt
A statement.
SwitchBody
The braced body of a switch.
SwitchCase
A case or default arm.
SwitchStmt
A switch statement.
TernaryExpr
A ternary or short-ternary conditional.
TraitAdaptation
A insteadof or as rule in a trait use.
TraitDecl
A trait declaration.
TraitUseDecl
A use Trait; clause inside a class.
TryCatchStmt
A try statement.
TypeHint
A type declaration.
UnaryPostfixExpr
A postfix unary operation.
UnaryPrefixExpr
A prefix unary operation.
UseDecl
A use import declaration.
UseItem
One imported name in a use declaration.
WhileStmt
A while loop.
YieldExpr
A yield or yield from expression.

Enums§

CallableCreateKind
The callee of a first-class callable.
ClassMemberKind
The kind of a class member.
EnumMemberKind
The kind of an enum member.
ExprKind
The kind of an expression.
NamespaceBody
Whether a namespace is braced or statement-terminated.
PropertyHookBody
The body of a property hook.
StmtKind
The kind of a statement.
StringPart
A segment of an interpolated string.
TraitAdaptationKind
The kind of trait adaptation rule.
TypeHintKind
The shape of a type declaration.

Functions§

from_owned_program
Convert an owned Program into an arena-allocated Program.
to_owned_expr
Convert an arena-allocated Expr into an Expr.
to_owned_name
Convert an arena-allocated Name into a Name.
to_owned_program
Convert an arena-allocated Program into a Program.
to_owned_stmt
Convert an arena-allocated Stmt into a Stmt.
to_owned_type_hint
Convert an arena-allocated TypeHint into a TypeHint.

Type Aliases§

Ident
Owned equivalent of Ident. None represents the error state (no identifier was parsed).