Skip to content

Commit ac4de81

Browse files
committed
analog fix in tagged union narrowing
1 parent ce2c4cd commit ac4de81

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

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

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ class CountWithOptionalKeys
222222
/**
223223
* @param array{0: mixed, 1?: string|null} $row
224224
*/
225-
protected function testOptionalKeys(array $row): void
225+
protected function testOptionalKeys($row): void
226226
{
227227
if (count($row) === 0) {
228228
assertType('*NEVER*', $row);
@@ -252,7 +252,7 @@ protected function testOptionalKeys(array $row): void
252252
/**
253253
* @param array{mixed}|array{0: mixed, 1?: string|null} $row
254254
*/
255-
protected function testOptionalKeysInUnion(array $row): void
255+
protected function testOptionalKeysInUnion($row): void
256256
{
257257
if (count($row) === 0) {
258258
assertType('*NEVER*', $row);
@@ -280,32 +280,32 @@ protected function testOptionalKeysInUnion(array $row): void
280280
}
281281

282282
/**
283-
* @param array{string}|array{0: mixed, 1?: string|null} $row
283+
* @param array{string}|array{0: int, 1?: string|null} $row
284284
*/
285-
protected function testOptionalKeysInTaggedUnion(array $row): void
285+
protected function testOptionalKeysInTaggedUnion($row): void
286286
{
287287
if (count($row) === 0) {
288288
assertType('*NEVER*', $row);
289289
} else {
290-
assertType('array{0: mixed, 1?: string|null}', $row);
290+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
291291
}
292292

293293
if (count($row) === 1) {
294-
assertType('array{mixed}', $row);
294+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
295295
} else {
296-
assertType('array{0: mixed, 1?: string|null}', $row);
296+
assertType('array{0: int, 1?: string|null}', $row);
297297
}
298298

299299
if (count($row) === 2) {
300-
assertType('array{mixed, string|null}', $row);
300+
assertType('array{int, string|null}', $row);
301301
} else {
302-
assertType('array{0: mixed, 1?: string|null}', $row);
302+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
303303
}
304304

305305
if (count($row) === 3) {
306306
assertType('*NEVER*', $row);
307307
} else {
308-
assertType('array{0: mixed, 1?: string|null}', $row);
308+
assertType('array{0: int, 1?: string|null}|array{string}', $row);
309309
}
310310
}
311311

0 commit comments

Comments
 (0)