Skip to content

Commit d6d136b

Browse files
committed
fix test
1 parent 73448a4 commit d6d136b

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/Rector/AbstractRector.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44

55
namespace Rector\Rector;
66

7-
use PhpParser\Builder\FunctionLike;
87
use PhpParser\Node;
8+
use PhpParser\Node\FunctionLike;
99
use PhpParser\Node\Name;
1010
use PhpParser\Node\PropertyItem;
1111
use PhpParser\Node\Stmt\Class_;
@@ -310,13 +310,18 @@ private function decorateCurrentAndChildren(Node $node): void
310310
static fn (string $nodeType): bool => $nodeType !== $node::class
311311
);
312312

313-
$this->traverseNodesWithCallable($node, static function (Node $subNode) use ($otherTypes): int|Node {
313+
$this->traverseNodesWithCallable($node, static function (Node $subNode) use ($node, $otherTypes): null|int|Node {
314314
// early check here as included in other types defined in getNodeTypes()
315315
if (in_array($subNode::class, $otherTypes, true)) {
316316
$subNode->setAttribute(AttributeKey::SKIPPED_BY_RECTOR_RULE, static::class);
317317
return $subNode;
318318
}
319319

320+
// already set
321+
if ($node === $subNode) {
322+
return null;
323+
}
324+
320325
// inner class/function are out of scope
321326
if ($subNode instanceof Class_ || $subNode instanceof FunctionLike) {
322327
return NodeVisitor::DONT_TRAVERSE_CURRENT_AND_CHILDREN;

0 commit comments

Comments
 (0)