Skip to content

Commit 3fd7428

Browse files
committed
cs
1 parent f091476 commit 3fd7428

2 files changed

Lines changed: 7 additions & 21 deletions

File tree

rules-tests/CodeQuality/Rector/Class_/CompleteDynamicPropertiesRector/Fixture/skip_anonymous_class.php.inc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ class SkipAnonymousClass
1818
$nodes = $nodes ? [$nodes] : [];
1919
}
2020

21-
$nodeTraverser = new NodeTraverser();
22-
$nodeTraverser->addVisitor($this->createNodeVisitor($callable));
21+
$nodeTraverser = new NodeTraverser(...$this->createNodeVisitor($callable));
2322
$nodeTraverser->traverse($nodes);
2423
}
2524

src/PhpParser/NodeTraverser/AbstractImmutableNodeTraverser.php

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)