psalm
psalm copied to clipboard
Psalm forgets about unset assertion outside of if
https://psalm.dev/r/2a90fda384
I found these snippets:
https://psalm.dev/r/2a90fda384
<?php
/** @var non-empty-array<string|int, int> */
$test = ['test' => 0];
/** @var string|int */
$k = 'test';
if (isset($test[$k])) {
unset($test[$k]);
/** @psalm-trace $test */
}
/** @psalm-trace $test */
Psalm output (using commit 028ac7f):
INFO: Trace - 8:0 - $test: array<int|string, int>
INFO: Trace - 11:26 - $test: non-empty-array<int|string, int>