Skip to content

Commit cb35a10

Browse files
staabmondrejmirtes
authored andcommitted
add test
1 parent 3ab9c4f commit cb35a10

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/PHPStan/Analyser/nsrt/narrow-tagged-union.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,17 @@ public function nestedArrays(array $arr): void
7979
assertType("array{array<int>, numeric-string}|array{string, '', non-empty-string}", $arr);
8080
}
8181

82+
/** @param array{string, '', non-empty-string}|array<int> $arr */
83+
public function mixedArrays(array $arr): void
84+
{
85+
if (count($arr, COUNT_NORMAL) === 3) {
86+
assertType("non-empty-array<int|string>", $arr); // could be array{string, '', non-empty-string}|non-empty-array<int>
87+
} else {
88+
assertType("array<int|string>", $arr); // could be array{string, '', non-empty-string}|array<int>
89+
}
90+
assertType("array<int|string>", $arr); // could be array{string, '', non-empty-string}|array<int>
91+
}
92+
8293
public function arrayIntRangeSize(): void
8394
{
8495
$x = [];

0 commit comments

Comments
 (0)