Skip to content

Commit 64793f6

Browse files
Add test
1 parent 61b98ea commit 64793f6

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

tests/PHPStan/Rules/Variables/data/bug-12364.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,20 @@ function foo(): array {
1717
assertType('string|null', $y); // <-- should be: null|string
1818
var_dump($x);
1919
var_dump($y); // <-- does exist
20+
21+
/** @return array{xx: string, yy?: string} */
22+
function foo2(): array {
23+
return [ 'xx' => 'foo' ];
24+
}
25+
26+
if (rand(0, 1)) {
27+
$xx = $yy = null;
28+
assertType('null', $xx);
29+
assertType('null', $yy);
30+
}
31+
32+
extract(foo2());
33+
assertType('string', $xx);
34+
assertType('string|null', $yy); // <-- should be: null|string
35+
var_dump($xx);
36+
var_dump($yy); // <-- does exist

0 commit comments

Comments
 (0)