diff --git a/src/Rector/AbstractRector.php b/src/Rector/AbstractRector.php index e5e5c0ecc6e..88a96adf812 100644 --- a/src/Rector/AbstractRector.php +++ b/src/Rector/AbstractRector.php @@ -226,12 +226,17 @@ private function decorateCurrentAndChildren(Node $node): void // 1. registered in getNodesTypes() method // 2. different with current node type, as already decorated above // - $types = array_filter( + $otherTypes = array_filter( $this->getNodeTypes(), static fn (string $nodeType): bool => $nodeType !== $node::class ); - $this->traverseNodesWithCallable($node, static function (Node $subNode) use ($types) { - if (in_array($subNode::class, $types, true)) { + + if ($otherTypes === []) { + return; + } + + $this->traverseNodesWithCallable($node, static function (Node $subNode) use ($otherTypes) { + if (in_array($subNode::class, $otherTypes, true)) { $subNode->setAttribute(AttributeKey::SKIPPED_BY_RECTOR_RULE, static::class); $subNode->setAttribute(AttributeKey::SKIPPED_BY_RECTOR_RULE, static::class); }