forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbug-14328.php
More file actions
39 lines (31 loc) · 1.01 KB
/
bug-14328.php
File metadata and controls
39 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php // lint >= 8.2
declare(strict_types = 1);
namespace Bug14328;
class Foo {
public function returnThis(mixed $value): self {
return $this;
}
public static function returnSelf(mixed $value): self {
return new self();
}
}
function testMethodCallChainedWithMethodCall(): void {
$callback = fn (): never => throw new \Exception();
$x = (new Foo())->returnThis($callback())->returnThis('x');
$y = 'this will never run';
}
function testMethodCallChainedWithStaticCall(): void {
$callback = fn (): never => throw new \Exception();
$x = (new Foo())->returnThis($callback())::returnSelf('x');
$y = 'this will never run';
}
function testStaticCallChainedWithMethodCall(): void {
$callback = fn (): never => throw new \Exception();
$a = Foo::returnSelf($callback())->returnThis('x');
$b = 'this will never run either';
}
function testStaticCallChainedWithStaticCall(): void {
$callback = fn (): never => throw new \Exception();
$a = Foo::returnSelf($callback())::returnSelf('x');
$b = 'this will never run either';
}