@@ -18,31 +18,23 @@ abstract class AbstractImmutableNodeTraverser implements NodeTraverserInterface
1818 */
1919 protected array $ visitors = [];
2020
21- /**
22- * @var bool Whether traversal should be stopped
23- */
2421 private bool $ stopTraversal ;
2522
26- /**
27- * Create a traverser with the given visitors.
28- *
29- * @param NodeVisitor ...$visitors Node visitors
30- */
3123 public function __construct (NodeVisitor ...$ visitors )
3224 {
3325 $ this ->visitors = $ visitors ;
3426 }
3527
36- /**
37- * Adds a visitor.
38- *
39- * @param NodeVisitor $visitor Visitor to add
40- */
4128 public function addVisitor (NodeVisitor $ visitor ): void
4229 {
4330 $ this ->visitors [] = $ visitor ;
4431 }
4532
33+ public function removeVisitor (NodeVisitor $ visitor ): void
34+ {
35+ throw new LogicException ('Removing visitors is not supported in ' . static ::class);
36+ }
37+
4638 /**
4739 * Traverses an array of nodes using the registered visitors.
4840 *
@@ -75,11 +67,6 @@ public function traverse(array $nodes): array
7567 */
7668 abstract public function getVisitorsForNode (Node $ node ): array ;
7769
78- /**
79- * Recursively traverse a node.
80- *
81- * @param Node $node Node to traverse.
82- */
8370 private function traverseNode (Node $ node ): void
8471 {
8572 foreach ($ node ->getSubNodeNames () as $ name ) {
@@ -162,7 +149,7 @@ private function traverseNode(Node $node): void
162149 *
163150 * @param Node[] $nodes Array to traverse
164151 *
165- * @return array Result of traversal (may be original array or changed one)
152+ * @return Node[] Result of traversal (may be original array or changed one)
166153 */
167154 private function traverseArray (array $ nodes ): array
168155 {
0 commit comments