Skip to content

Commit 458f17a

Browse files
authored
fix: chained calls on static calls (#7746)
1 parent a69e335 commit 458f17a

File tree

2 files changed

+6
-8
lines changed

2 files changed

+6
-8
lines changed

rules-tests/CodingStyle/Rector/ArrowFunction/ArrowFunctionDelegatingCallToFirstClassCallableRector/Fixture/skip_chained_calls.php.inc

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,7 @@ final class SkipChainedCalls
66
{
77
public function run()
88
{
9-
function ($foo)
10-
{
11-
return FooBar::foo()->bar($foo);
12-
};
13-
149
fn ($foo) => FooBar::foo()->bar($foo);
10+
fn ($foo) => FooBar::foo()::bar($foo);
1511
}
1612
}

rules/CodingStyle/Guard/ArrowFunctionAndClosureFirstClassCallableGuard.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,13 @@ private function isUsingNamedArgs(array $args): bool
194194

195195
private function isChainedCall(FuncCall|MethodCall|StaticCall $callLike): bool
196196
{
197-
if (! $callLike instanceof MethodCall) {
198-
return false;
197+
if ($callLike instanceof MethodCall) {
198+
return $callLike->var instanceof CallLike;
199+
} elseif ($callLike instanceof StaticCall) {
200+
return $callLike->class instanceof CallLike;
199201
}
200202

201-
return $callLike->var instanceof CallLike;
203+
return false;
202204
}
203205

204206
/**

0 commit comments

Comments
 (0)