1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Add better support for previous key types

This commit is contained in:
Brown 2019-10-03 15:43:17 -04:00
parent 549aee47f1
commit ca06277f30
2 changed files with 12 additions and 1 deletions

View File

@ -722,7 +722,7 @@ class Reconciler
null
);
if (!$previous_key_type->isArrayKey()) {
if (!$previous_key_type->isEmpty()) {
$base_atomic_type->previous_key_type = $previous_key_type;
}
$base_atomic_type->previous_value_type = $previous_value_type;

View File

@ -290,6 +290,17 @@ class AssertTest extends TestCase
$arr[$a->id]->foo();
}'
],
'assertAfterNotEmptyArrayCheck' => [
'<?php
function foo(array $c): void {
if (!empty($c["d"])) {}
foreach (["a", "b", "c"] as $k) {
/** @psalm-suppress MixedAssignment */
foreach ($c[$k] as $d) {}
}
}',
]
];
}
}