Expand description
Visitor infrastructure for owned (lifetime-free) PHP AST traversal.
This module mirrors crate::visitor but operates on the owned AST types
in crate::owned rather than the arena-allocated types. Use it after
calling [php_rs_parser::parse()] — no arena or lifetime management needed.
§Example
use php_ast::owned::visitor::{OwnedVisitor, walk_owned_expr};
use php_ast::owned::{Expr, ExprKind};
use std::ops::ControlFlow;
struct VarCounter { count: usize }
impl OwnedVisitor for VarCounter {
fn visit_expr(&mut self, expr: &Expr) -> ControlFlow<()> {
if matches!(&expr.kind, ExprKind::Variable(_)) {
self.count += 1;
}
walk_owned_expr(self, expr)
}
}Structs§
- Owned
Scope - Lexical scope context for owned AST traversal.
- Owned
Scope Walker - Drives an
OwnedScopeVisitorover an owned AST, maintainingOwnedScopeautomatically.
Traits§
- Owned
Scope Visitor - A scope-aware variant of
OwnedVisitor. - Owned
Visitor - Visitor trait for immutable traversal of owned (lifetime-free) AST nodes.
Functions§
- walk_
owned_ arg - Visits the value expression of a call argument.
- walk_
owned_ attribute - Visits an attribute’s name and argument expressions.
- walk_
owned_ catch_ clause - Visits a catch clause’s type names and body statements.
- walk_
owned_ class_ member - Dispatches a class member to its child visitors.
- walk_
owned_ comments - Calls
OwnedVisitor::visit_commentfor each comment incomments. - walk_
owned_ enum_ member - Dispatches an enum member to its child visitors.
- walk_
owned_ expr - Dispatches
exprto the appropriate child visitors based on itsExprKind. - walk_
owned_ match_ arm - Visits a match arm’s condition expressions and body expression.
- walk_
owned_ name - Calls
OwnedVisitor::visit_nameonname. - walk_
owned_ param - Visits a function/method parameter’s attributes, type hint, default, and hooks.
- walk_
owned_ program - Visits every top-level statement in
program. - walk_
owned_ property_ hook - Visits a property hook’s attributes, parameters, and body.
- walk_
owned_ stmt - Dispatches
stmtto the appropriate child visitors based on itsStmtKind. - walk_
owned_ trait_ use - Visits a trait use declaration’s names and adaptations.
- walk_
owned_ type_ hint - Visits the inner types of a type hint.