Skip to content

Commit 9f4771a

Browse files
Add test
1 parent 61b98ea commit 9f4771a

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,24 @@ 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+
function testUndefined()
27+
{
28+
if (rand(0, 1)) {
29+
$xx = $yy = 0;
30+
assertType('0', $xx);
31+
assertType('0', $yy);
32+
}
33+
34+
extract(foo2());
35+
assertType('string', $xx);
36+
37+
if (isset($yy)) {
38+
assertType('0|string', $yy);
39+
}
40+
}

0 commit comments

Comments
 (0)