Skip to content

Commit c9bd900

Browse files
phpstan-botclaude
andcommitted
Add test for static-to-static chained call (::) unreachable detection
The previous tests covered static calls chained with instance method calls (->), but not static calls chained with other static calls (::). This new test exercises the StaticCallHandler fix where the class expression is itself a static call with a never-returning argument. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 149e50c commit c9bd900

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

tests/PHPStan/Rules/DeadCode/UnreachableStatementRuleTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,6 +390,10 @@ public function testBug14328(): void
390390
'Unreachable statement - code above always terminates.',
391391
37,
392392
],
393+
[
394+
'Unreachable statement - code above always terminates.',
395+
43,
396+
],
393397
]);
394398
}
395399

tests/PHPStan/Rules/DeadCode/data/bug-14328.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,14 @@ function testStaticCall(): void {
3131
$b = 'this will never run';
3232
}
3333

34-
function testStaticCallChained(): void {
34+
function testStaticCallChainedWithMethodCall(): void {
3535
$callback = fn (): never => throw new \Exception();
3636
$a = Foo::staticReturnSelf($callback())->returnThis('x');
3737
$b = 'this will never run either';
3838
}
39+
40+
function testStaticCallChainedWithStaticCall(): void {
41+
$callback = fn (): never => throw new \Exception();
42+
$a = Foo::staticReturnSelf($callback())::staticReturnSelf('x');
43+
$b = 'this will never run either';
44+
}

0 commit comments

Comments
 (0)