From 9a3b2c3a99940ab8114341756e4eb23b692d5e4c Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 18 Dec 2025 15:10:48 +0700 Subject: [PATCH] [Php81] Skip as Arg value on ArrayToFirstClassCallableRector --- .../Fixture/make_other_closure_pass.php.inc | 27 ------------------- ...value_with_caller_param_type_array.php.inc | 18 +++++++++++++ .../skip_as_service_factory_arg.php.inc | 11 ++++++++ .../ArrayCallableMethodMatcher.php | 4 +++ 4 files changed, 33 insertions(+), 27 deletions(-) delete mode 100644 rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc create mode 100644 rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_arg_value_with_caller_param_type_array.php.inc create mode 100644 rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_service_factory_arg.php.inc diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc deleted file mode 100644 index f125926e8bd..00000000000 --- a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/make_other_closure_pass.php.inc +++ /dev/null @@ -1,27 +0,0 @@ -services() - ->factory([SomeExternalObject::class, 'sleepStatic']); -}; - -?> ------ -services() - ->factory(SomeExternalObject::sleepStatic(...)); -}; - -?> diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_arg_value_with_caller_param_type_array.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_arg_value_with_caller_param_type_array.php.inc new file mode 100644 index 00000000000..857505b3513 --- /dev/null +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_arg_value_with_caller_param_type_array.php.inc @@ -0,0 +1,18 @@ +run([$this, 'some']); + } + + public function some() + {} +} \ No newline at end of file diff --git a/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_service_factory_arg.php.inc b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_service_factory_arg.php.inc new file mode 100644 index 00000000000..cd2c9ccf210 --- /dev/null +++ b/rules-tests/Php81/Rector/Array_/ArrayToFirstClassCallableRector/Fixture/skip_as_service_factory_arg.php.inc @@ -0,0 +1,11 @@ +services() + ->factory([SomeExternalObject::class, 'sleepStatic']); +}; diff --git a/src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php b/src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php index d655ca56113..0cf7995eabb 100644 --- a/src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php +++ b/src/NodeCollector/NodeAnalyzer/ArrayCallableMethodMatcher.php @@ -72,6 +72,10 @@ public function match( return null; } + if ($array->getAttribute(AttributeKey::IS_ARG_VALUE) === true) { + return null; + } + $values = $this->valueResolver->getValue($array); $className = $callerType->getClassName(); $secondItemValue = $items[1]->value;