Skip to content

Commit b686f79

Browse files
committed
more tests
1 parent 0421518 commit b686f79

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
@@ -249,4 +249,34 @@ protected function testOptionalKeys(array $row): void
249249
}
250250
}
251251

252+
/**
253+
* @param array{mixed}|array{0: mixed, 1?: string|null} $row
254+
*/
255+
protected function testOptionalKeysInUnion(array $row): void
256+
{
257+
if (count($row) === 0) {
258+
assertType('*NEVER*', $row);
259+
} else {
260+
assertType('array{0: mixed, 1?: string|null}', $row);
261+
}
262+
263+
if (count($row) === 1) {
264+
assertType('array{mixed}', $row);
265+
} else {
266+
assertType('array{0: mixed, 1?: string|null}', $row);
267+
}
268+
269+
if (count($row) === 2) {
270+
assertType('array{mixed, string|null}', $row);
271+
} else {
272+
assertType('array{0: mixed, 1?: string|null}', $row);
273+
}
274+
275+
if (count($row) === 3) {
276+
assertType('*NEVER*', $row);
277+
} else {
278+
assertType('array{0: mixed, 1?: string|null}', $row);
279+
}
280+
}
281+
252282
}

0 commit comments

Comments
 (0)