Skip to content

Commit 32abd99

Browse files
Add test
1 parent 9e28672 commit 32abd99

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

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

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,36 @@ public static function doSomethingFor(X $x): void {
4242
}
4343
}
4444
}
45+
46+
enum Y: string {
47+
case A = 'a';
48+
case B = 'b';
49+
case C = 'c';
50+
51+
/** @param-out ($this is self::A ? int : null) $i */
52+
public function get(?int &$i): void {
53+
($this === self::A) ? $i=null : $i=123;
54+
}
55+
56+
public function doSomething(): void {
57+
$i = 0;
58+
if ($this !== self::A) {
59+
$this->get($i);
60+
assertType('null', $i); // null
61+
} else {
62+
$this->get($i);
63+
assertType('int', $i); // int
64+
}
65+
}
66+
67+
public static function doSomethingFor(Y $x): void {
68+
$i = 0;
69+
if ($x !== self::A) {
70+
$x->get($i);
71+
assertType('null', $i); // null
72+
} else {
73+
$x->get($i);
74+
assertType('int', $i); // int
75+
}
76+
}
77+
}

0 commit comments

Comments
 (0)