From 162179c6339fae93900b97d19529bc0c6e68f0c6 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 2 Jun 2023 06:49:27 +0700 Subject: [PATCH 1/2] [CodingStyle] Skip first class callable on UnSpreadOperatorRector --- .../Fixture/skip_first_class_callable.php.inc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 rules-tests/CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector/Fixture/skip_first_class_callable.php.inc 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; + } +} From c91eb7ff8cf65711b36118827177e701505a3e7f Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Fri, 2 Jun 2023 06:50:13 +0700 Subject: [PATCH 2/2] Fixed :tada: --- .../CodingStyle/Rector/ClassMethod/UnSpreadOperatorRector.php | 4 ++++ 1 file changed, 4 insertions(+) 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;