From be0e6a32c33aa95dbd0581a3c62d33c0af73354a Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Apr 2026 00:13:02 +0700 Subject: [PATCH 1/3] [Php81] Handle crash on normal array with variadic inside class on ArrayToFirstClassCallableRector --- .../Fixture/skip_normal_array_with_variadic.php.inc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_normal_array_with_variadic.php.inc 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'); + } +} From 5fff706e209e8252d0ebef5d129ca47dc120f9b6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Apr 2026 00:19:30 +0700 Subject: [PATCH 2/3] Fix --- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index 08ac4123966..f8815f9d2ba 100644 --- a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php +++ b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php @@ -492,6 +492,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 From f9558c140ac0b3b949b59f3e60789def78c65f95 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Apr 2026 00:20:47 +0700 Subject: [PATCH 3/3] clean up --- .../PHPStan/Scope/PHPStanNodeScopeResolver.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php b/src/NodeTypeResolver/PHPStan/Scope/PHPStanNodeScopeResolver.php index f8815f9d2ba..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);