\PhpParserNodeTraverser

Summary

Methods
Properties
Constants
__construct()
addVisitor()
removeVisitor()
traverse()
No public properties found
DONT_TRAVERSE_CHILDREN
STOP_TRAVERSAL
REMOVE_NODE
traverseNode()
traverseArray()
$visitors
$stopTraversal
N/A
No private methods found
No private properties found
N/A

Constants

DONT_TRAVERSE_CHILDREN

DONT_TRAVERSE_CHILDREN = 1

If NodeVisitor::enterNode() returns DONT_TRAVERSE_CHILDREN, child nodes of the current node will not be traversed for any visitors.

For subsequent visitors enterNode() will still be called on the current node and leaveNode() will also be invoked for the current node.

STOP_TRAVERSAL

STOP_TRAVERSAL = 2

If NodeVisitor::enterNode() or NodeVisitor::leaveNode() returns STOP_TRAVERSAL, traversal is aborted.

The afterTraverse() method will still be invoked.

REMOVE_NODE

REMOVE_NODE = false

If NodeVisitor::leaveNode() returns REMOVE_NODE for a node that occurs in an array, it will be removed from the array.

For subsequent visitors leaveNode() will still be invoked for the removed node.

Properties

$visitors

$visitors : array<mixed,\PhpParser\NodeVisitor>

Type

array<mixed,\PhpParser\NodeVisitor> — Visitors

$stopTraversal

$stopTraversal : boolean

Type

boolean — Whether traversal should be stopped

Methods

__construct()

__construct() 

Constructs a node traverser.

addVisitor()

addVisitor(\PhpParser\NodeVisitor  $visitor) 

Adds a visitor.

Parameters

\PhpParser\NodeVisitor $visitor

Visitor to add

removeVisitor()

removeVisitor(\PhpParser\NodeVisitor  $visitor) 

Removes an added visitor.

Parameters

\PhpParser\NodeVisitor $visitor

traverse()

traverse(array<mixed,\PhpParser\Node>  $nodes) : array<mixed,\PhpParser\Node>

Traverses an array of nodes using the registered visitors.

Parameters

array<mixed,\PhpParser\Node> $nodes

Array of nodes

Returns

array<mixed,\PhpParser\Node> —

Traversed array of nodes

traverseNode()

traverseNode(\PhpParser\Node  $node) 

Parameters

\PhpParser\Node $node

traverseArray()

traverseArray(array  $nodes) 

Parameters

array $nodes