Skip to content

Commit

Permalink
Skip arrow function in scoped search (#6333)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasVotruba authored Sep 28, 2024
1 parent 319e244 commit 80f7e5b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PhpParser/Node/BetterNodeFinder.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\PhpParser\Node;

use PhpParser\Node;
use PhpParser\Node\Expr\ArrowFunction;
use PhpParser\Node\Expr\Closure;
use PhpParser\Node\Expr\Variable;
use PhpParser\Node\Expr\Yield_;
Expand Down Expand Up @@ -170,7 +171,7 @@ public function hasInstancesOfInFunctionLikeScoped(
$this->simpleCallableNodeTraverser->traverseNodesWithCallable(
(array) $functionLike->stmts,
static function (Node $subNode) use ($types, &$isFoundNode): ?int {
if ($subNode instanceof Class_ || $subNode instanceof Function_ || $subNode instanceof Closure) {
if ($subNode instanceof Class_ || $subNode instanceof Function_ || $subNode instanceof Closure || $subNode instanceof ArrowFunction) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

Expand Down Expand Up @@ -246,7 +247,7 @@ public function findInstancesOfScoped(array $nodes, string|array $types): array
$this->simpleCallableNodeTraverser->traverseNodesWithCallable(
$nodes,
static function (Node $subNode) use ($types, &$foundNodes): ?int {
if ($subNode instanceof Class_ || $subNode instanceof Function_ || $subNode instanceof Closure) {
if ($subNode instanceof Class_ || $subNode instanceof Function_ || $subNode instanceof Closure || $subNode instanceof ArrowFunction) {
return NodeTraverser::DONT_TRAVERSE_CURRENT_AND_CHILDREN;
}

Expand Down

0 comments on commit 80f7e5b

Please sign in to comment.