Skip to content

Commit 06ae0bd

Browse files
phpstan-botVincentLanglet
authored andcommitted
Add regression test for #12401
Closes phpstan/phpstan#12401
1 parent c5a4140 commit 06ae0bd

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php declare(strict_types = 1);
2+
3+
namespace Bug12401;
4+
5+
use function PHPStan\Testing\assertType;
6+
7+
/**
8+
* @param array{a: string, b: string}|array{c: string} $data
9+
*/
10+
function test(array $data): void {
11+
if (isset($data['a'])) {
12+
assertType('array{a: string, b: string}', $data);
13+
} else {
14+
assertType('array{c: string}', $data);
15+
}
16+
17+
if (isset($data['a'])) {
18+
assertType('array{a: string, b: string}', $data);
19+
} elseif (isset($data['c'])) {
20+
assertType('array{c: string}', $data);
21+
} else {
22+
assertType('*NEVER*', $data);
23+
}
24+
}

0 commit comments

Comments
 (0)