NodeTraverser
in package
implements
NodeTraverserInterface
Table of Contents
Interfaces
Constants
- DONT_TRAVERSE_CHILDREN = \PhpParser\NodeVisitor::DONT_TRAVERSE_CHILDREN
- DONT_TRAVERSE_CURRENT_AND_CHILDREN = \PhpParser\NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
- REMOVE_NODE = \PhpParser\NodeVisitor::REMOVE_NODE
- STOP_TRAVERSAL = \PhpParser\NodeVisitor::STOP_TRAVERSAL
Properties
- $stopTraversal : bool
- $visitors : array<int, NodeVisitor>
Methods
- __construct() : mixed
- Create a traverser with the given visitors.
- addVisitor() : void
- Adds a visitor.
- removeVisitor() : void
- Removes an added visitor.
- traverse() : array<string|int, Node>
- Traverses an array of nodes using the registered visitors.
- traverseArray() : array<string|int, mixed>
- Recursively traverse array (usually of nodes).
- traverseNode() : void
- Recursively traverse a node.
- ensureReplacementReasonable() : void
Constants
DONT_TRAVERSE_CHILDREN
public
mixed
DONT_TRAVERSE_CHILDREN
= \PhpParser\NodeVisitor::DONT_TRAVERSE_CHILDREN
Tags
DONT_TRAVERSE_CURRENT_AND_CHILDREN
public
mixed
DONT_TRAVERSE_CURRENT_AND_CHILDREN
= \PhpParser\NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN
Tags
REMOVE_NODE
public
mixed
REMOVE_NODE
= \PhpParser\NodeVisitor::REMOVE_NODE
Tags
STOP_TRAVERSAL
public
mixed
STOP_TRAVERSAL
= \PhpParser\NodeVisitor::STOP_TRAVERSAL
Tags
Properties
$stopTraversal
protected
bool
$stopTraversal
Whether traversal should be stopped
$visitors
protected
array<int, NodeVisitor>
$visitors
= []
Visitors
Methods
__construct()
Create a traverser with the given visitors.
public
__construct(NodeVisitor ...$visitors) : mixed
Parameters
- $visitors : NodeVisitor
-
Node visitors
addVisitor()
Adds a visitor.
public
addVisitor(NodeVisitor $visitor) : void
Parameters
- $visitor : NodeVisitor
-
Visitor to add
removeVisitor()
Removes an added visitor.
public
removeVisitor(NodeVisitor $visitor) : void
Parameters
- $visitor : NodeVisitor
traverse()
Traverses an array of nodes using the registered visitors.
public
traverse(array<string|int, Node> $nodes) : array<string|int, Node>
Parameters
- $nodes : array<string|int, Node>
-
Array of nodes
Return values
array<string|int, Node> —Traversed array of nodes
traverseArray()
Recursively traverse array (usually of nodes).
protected
traverseArray(array<string|int, mixed> $nodes) : array<string|int, mixed>
Parameters
- $nodes : array<string|int, mixed>
-
Array to traverse
Return values
array<string|int, mixed> —Result of traversal (may be original array or changed one)
traverseNode()
Recursively traverse a node.
protected
traverseNode(Node $node) : void
Parameters
- $node : Node
-
Node to traverse.
ensureReplacementReasonable()
private
ensureReplacementReasonable(Node $old, Node $new) : void