diff --git a/rules-tests/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector/Fixture/skip_first_class_callable.php.inc b/rules-tests/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector/Fixture/skip_first_class_callable.php.inc new file mode 100644 index 00000000000..b1264cad9b4 --- /dev/null +++ b/rules-tests/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector/Fixture/skip_first_class_callable.php.inc @@ -0,0 +1,17 @@ +callback(...), + array: $array, + ); + } + + private function callback(int $value): string { + return (string) $value; + } +} diff --git a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php index b9c0f1c71a8..f7eac8f7819 100644 --- a/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php +++ b/rules/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php @@ -122,6 +122,10 @@ private function refactorClassMethod(ClassMethod $classMethod): ?ClassMethod private function refactorMethodCall(MethodCall $methodCall, Scope $scope): ?MethodCall { + if ($methodCall->isFirstClassCallable()) { + return null; + } + $methodReflection = $this->reflectionResolver->resolveMethodReflectionFromMethodCall($methodCall); if (! $methodReflection instanceof MethodReflection) { return null;