1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Negation of numeric on array-key is fine too

This commit is contained in:
Matthew Brown 2020-02-22 12:53:27 -05:00
parent 6adf6a09f0
commit 2635e57cde
2 changed files with 4 additions and 0 deletions

View File

@ -1007,6 +1007,9 @@ class NegatedAssertionReconciler extends Reconciler
$non_numeric_types[] = $type;
}
} elseif ($type instanceof TArrayKey) {
$did_remove_type = true;
$non_numeric_types[] = new TString();
} elseif (!$type->isNumericType()) {
$non_numeric_types[] = $type;
} else {

View File

@ -1038,6 +1038,7 @@ class TypeTest extends \Psalm\Tests\TestCase
function foo(array $arr) : void {
foreach ($arr as $k => $_) {
if (is_numeric($k)) {}
if (!is_numeric($k)) {}
}
}'
],