Skip to content

Commit 62cf374

Browse files
phpstan-botclaude
andcommitted
Add static method tests to bug-5207 regression test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 656a527 commit 62cf374

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/PHPStan/Analyser/nsrt/bug-5207.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,43 @@ public function sayHelloInline(): void {
2323
}
2424
}
2525

26+
abstract class StaticWorld {
27+
abstract public static function getChild(): ?StaticWorld;
28+
29+
public static function sayHello(): void {
30+
$foo = null !== static::getChild();
31+
if ($foo) {
32+
assertType('Bug5207\StaticWorld', static::getChild());
33+
}
34+
}
35+
36+
public static function sayHelloInline(): void {
37+
if (null !== static::getChild()) {
38+
assertType('Bug5207\StaticWorld', static::getChild());
39+
}
40+
}
41+
}
42+
43+
abstract class ImpureStaticWorld {
44+
/**
45+
* @phpstan-impure
46+
*/
47+
abstract public static function getChild(): ?ImpureStaticWorld;
48+
49+
public static function sayHello(): void {
50+
$foo = null !== static::getChild();
51+
if ($foo) {
52+
assertType('Bug5207\ImpureStaticWorld|null', static::getChild());
53+
}
54+
}
55+
56+
public static function sayHelloInline(): void {
57+
if (null !== static::getChild()) {
58+
assertType('Bug5207\ImpureStaticWorld|null', static::getChild());
59+
}
60+
}
61+
}
62+
2663
abstract class ImpureWorld {
2764
/**
2865
* @phpstan-impure

0 commit comments

Comments
 (0)