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
ArrayAccessExpr
ArrayElement
ArrowFunctionExpr
AssignExpr
Attribute
BinaryExpr
CallableCreateExpr
CatchClause
ClassConstDecl
ClassDecl
ClassMember
ClosureExpr
ClosureUseVar
Comment
ConstItem
DeclareStmt
DoWhileStmt
ElseIfBranch
EnumCase
EnumDecl
EnumMember
Expr
ForStmt
ForeachStmt
FunctionCallExpr
FunctionDecl
IfStmt
InterfaceDecl
MatchArm
MatchExpr
MethodCallExpr
MethodDecl
Name
NamespaceDecl
NewExpr
NullCoalesceExpr
Param
Program
PropertyAccessExpr
PropertyDecl
PropertyHook
StaticAccessExpr
StaticDynMethodCallExpr
StaticMethodCallExpr
StaticVar
Stmt
SwitchCase
SwitchStmt
TernaryExpr
TraitAdaptation
TraitDecl
TraitUseDecl
TryCatchStmt
TypeHint
UnaryPostfixExpr
UnaryPrefixExpr
UseDecl
UseItem
WhileStmt
YieldExpr

Enums§

CallableCreateKind
ClassMemberKind
EnumMemberKind
ExprKind
NamespaceBody
PropertyHookBody
StmtKind
StringPart
TraitAdaptationKind
TypeHintKind

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_program
Convert an arena-allocated Program into a Program.
to_owned_stmt
Convert an arena-allocated Stmt into a Stmt.

Type Aliases§

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