Skip to content

Commit ce2c4cd

Browse files
committed
more tests
1 parent b686f79 commit ce2c4cd

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/PHPStan/Analyser/nsrt/list-count.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -279,4 +279,34 @@ protected function testOptionalKeysInUnion(array $row): void
279279
}
280280
}
281281

282+
/**
283+
* @param array{string}|array{0: mixed, 1?: string|null} $row
284+
*/
285+
protected function testOptionalKeysInTaggedUnion(array $row): void
286+
{
287+
if (count($row) === 0) {
288+
assertType('*NEVER*', $row);
289+
} else {
290+
assertType('array{0: mixed, 1?: string|null}', $row);
291+
}
292+
293+
if (count($row) === 1) {
294+
assertType('array{mixed}', $row);
295+
} else {
296+
assertType('array{0: mixed, 1?: string|null}', $row);
297+
}
298+
299+
if (count($row) === 2) {
300+
assertType('array{mixed, string|null}', $row);
301+
} else {
302+
assertType('array{0: mixed, 1?: string|null}', $row);
303+
}
304+
305+
if (count($row) === 3) {
306+
assertType('*NEVER*', $row);
307+
} else {
308+
assertType('array{0: mixed, 1?: string|null}', $row);
309+
}
310+
}
311+
282312
}

0 commit comments

Comments
 (0)