diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_normal_array_with_variadic.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_normal_array_with_variadic.php.inc new file mode 100644 index 00000000000..0648b44e32a --- /dev/null +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_normal_array_with_variadic.php.inc @@ -0,0 +1,13 @@ +foo('first', ['key' => 'value'], c: 'test'); + } +} diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 08ac4123966..d66d08bd15d 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -6,7 +6,6 @@ use Error; use PhpParser\Node; -use PhpParser\Node\Arg; use PhpParser\Node\ArrayItem; use PhpParser\Node\Expr; use PhpParser\Node\Expr\Array_; @@ -277,11 +276,6 @@ public function processNodes( return; } - if ($node instanceof Arg) { - $node->value->setAttribute(AttributeKey::SCOPE, $mutatingScope); - return; - } - if ($node instanceof Foreach_) { // decorate value as well $node->valueVar->setAttribute(AttributeKey::SCOPE, $mutatingScope); @@ -492,6 +486,14 @@ private function processCallLike(CallLike $callLike, MutatingScope $mutatingScop } elseif ($callLike instanceof New_ && ! $callLike->class instanceof Class_) { $callLike->class->setAttribute(AttributeKey::SCOPE, $mutatingScope); } + + if ($callLike->isFirstClassCallable()) { + return; + } + + foreach ($callLike->getArgs() as $arg) { + $arg->value->setAttribute(AttributeKey::SCOPE, $mutatingScope); + } } private function processAssign(Assign|AssignOp|AssignRef $assign, MutatingScope $mutatingScope): void