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

Disable list flag for TKeyedArray after unset

This commit is contained in:
orklah 2021-11-26 20:52:34 +01:00
parent b42c2814a9
commit 4f223db455
2 changed files with 8 additions and 0 deletions

View File

@ -50,6 +50,7 @@ class UnsetAnalyzer
|| $var->dim instanceof PhpParser\Node\Scalar\LNumber
) {
if (isset($atomic_root_type->properties[$var->dim->value])) {
$atomic_root_type->is_list = false;
unset($atomic_root_type->properties[$var->dim->value]);
$root_type->bustCache(); //remove id cache
}

View File

@ -1024,6 +1024,13 @@ class ArrayAccessTest extends TestCase
return $p["name"];
}'
],
'unsetListKeyedArrayDisableListFlag' => [
'<?php
$a = ["a", "b"];
unset($a[0]);
',
'assertions' => ['$a===' => 'array{1: "b"}']
],
];
}