From 540c2637aee3746a1b9b8895f8f96145ca5752f4 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Tue, 9 Dec 2025 10:58:29 -0600 Subject: [PATCH] fix: chained calls on static calls --- .../Fixture/skip_chained_calls.php.inc | 6 +----- .../ArrowFunctionAndClosureFirstClassCallableGuard.php | 8 +++++--- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/rules-tests/CodingStyle/Rector/ArrowFunction/ArrowFunctionDelegatingCallToFirstClassCallableRector/Fixture/skip_chained_calls.php.inc b/rules-tests/CodingStyle/Rector/ArrowFunction/ArrowFunctionDelegatingCallToFirstClassCallableRector/Fixture/skip_chained_calls.php.inc index 15b25385a57..6445ba2db7e 100644 --- a/rules-tests/CodingStyle/Rector/ArrowFunction/ArrowFunctionDelegatingCallToFirstClassCallableRector/Fixture/skip_chained_calls.php.inc +++ b/rules-tests/CodingStyle/Rector/ArrowFunction/ArrowFunctionDelegatingCallToFirstClassCallableRector/Fixture/skip_chained_calls.php.inc @@ -6,11 +6,7 @@ final class SkipChainedCalls { public function run() { - function ($foo) - { - return FooBar::foo()->bar($foo); - }; - fn ($foo) => FooBar::foo()->bar($foo); + fn ($foo) => FooBar::foo()::bar($foo); } } diff --git a/rules/CodingStyle/Guard/ArrowFunctionAndClosureFirstClassCallableGuard.php b/rules/CodingStyle/Guard/ArrowFunctionAndClosureFirstClassCallableGuard.php index 661f7482c00..7b709d5e3f7 100644 --- a/rules/CodingStyle/Guard/ArrowFunctionAndClosureFirstClassCallableGuard.php +++ b/rules/CodingStyle/Guard/ArrowFunctionAndClosureFirstClassCallableGuard.php @@ -194,11 +194,13 @@ private function isUsingNamedArgs(array $args): bool private function isChainedCall(FuncCall|MethodCall|StaticCall $callLike): bool { - if (! $callLike instanceof MethodCall) { - return false; + if ($callLike instanceof MethodCall) { + return $callLike->var instanceof CallLike; + } elseif ($callLike instanceof StaticCall) { + return $callLike->class instanceof CallLike; } - return $callLike->var instanceof CallLike; + return false; } /**