Skip to content

Commit 0421518

Browse files
committed
fix
1 parent 766ee4e commit 0421518

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,12 +220,32 @@ function countCountable(CountableFoo $x, int $mode)
220220
class CountWithOptionalKeys
221221
{
222222
/**
223-
* @param array{mixed}|array{0: mixed, 1?: string|null} $row
223+
* @param array{0: mixed, 1?: string|null} $row
224224
*/
225225
protected function testOptionalKeys(array $row): void
226226
{
227+
if (count($row) === 0) {
228+
assertType('*NEVER*', $row);
229+
} else {
230+
assertType('array{0: mixed, 1?: string|null}', $row);
231+
}
232+
233+
if (count($row) === 1) {
234+
assertType('array{mixed}', $row);
235+
} else {
236+
assertType('array{0: mixed, 1?: string|null}', $row);
237+
}
238+
227239
if (count($row) === 2) {
228240
assertType('array{mixed, string|null}', $row);
241+
} else {
242+
assertType('array{0: mixed, 1?: string|null}', $row);
243+
}
244+
245+
if (count($row) === 3) {
246+
assertType('*NEVER*', $row);
247+
} else {
248+
assertType('array{0: mixed, 1?: string|null}', $row);
229249
}
230250
}
231251

0 commit comments

Comments
 (0)