From 102bda72e3101465414a08479772e3f81cc89237 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 24 Jun 2026 20:05:50 +0700 Subject: [PATCH 1/2] [Php81] Skip as ReflectionMethod argument unpack --- .../Fixture/skip_in_reflection_method.php.inc | 16 ++++++++++++++++ .../Array_/ArrayToFirstClassCallableRector.php | 4 ++++ src/NodeTypeResolver/Node/AttributeKey.php | 2 ++ src/PhpParser/NodeVisitor/ContextNodeVisitor.php | 4 ++++ 4 files changed, 26 insertions(+) create mode 100644 rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc new file mode 100644 index 00000000000..9fa15ffeeef --- /dev/null +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc @@ -0,0 +1,16 @@ +getAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE)) { + return null; + } + $args = [new VariadicPlaceholder()]; if ($callerExpr instanceof ClassConstFetch) { $type = $this->getType($callerExpr->class); diff --git a/src/NodeTypeResolver/Node/AttributeKey.php b/src/NodeTypeResolver/Node/AttributeKey.php index 1df957cdfac..24a9ed109e0 100644 --- a/src/NodeTypeResolver/Node/AttributeKey.php +++ b/src/NodeTypeResolver/Node/AttributeKey.php @@ -129,6 +129,8 @@ final class AttributeKey public const string IS_ARG_VALUE = 'is_arg_value'; + public const string IS_UNPACKED_ARG_VALUE = 'is_unpacked_arg_value'; + public const string IS_PARAM_VAR = 'is_param_var'; public const string IS_PARAM_DEFAULT = 'is_param_default'; diff --git a/src/PhpParser/NodeVisitor/ContextNodeVisitor.php b/src/PhpParser/NodeVisitor/ContextNodeVisitor.php index 4d147b6a9cb..94c53d446ab 100644 --- a/src/PhpParser/NodeVisitor/ContextNodeVisitor.php +++ b/src/PhpParser/NodeVisitor/ContextNodeVisitor.php @@ -94,6 +94,10 @@ public function enterNode(Node $node): ?Node if ($node instanceof Arg) { $node->value->setAttribute(AttributeKey::IS_ARG_VALUE, true); + if ($node->unpack) { + $node->value->setAttribute(AttributeKey::IS_UNPACKED_ARG_VALUE, true); + } + return null; } From 2297fd5bd5ece220c832f76a0e9a2087027a0ec1 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Wed, 24 Jun 2026 20:12:22 +0700 Subject: [PATCH 2/2] final touch: rename fixture --- ...inc => skip_in_reflection_method_as_argument_unpack.php.inc} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/{skip_in_reflection_method.php.inc => skip_in_reflection_method_as_argument_unpack.php.inc} (85%) diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method_as_argument_unpack.php.inc similarity index 85% rename from rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc rename to rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method_as_argument_unpack.php.inc index 9fa15ffeeef..1c507ae7671 100644 --- a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method.php.inc +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_in_reflection_method_as_argument_unpack.php.inc @@ -4,7 +4,7 @@ namespace Rector\Tests\Php81\Rector\Array_\ArrayToFirstClassCallableRector\Fixtu use ReflectionMethod; -class SkipInReflectionMethod +class SkipInReflectionMethodAsArgumentUnpack { function methodInjection() {}