psalm
psalm copied to clipboard
Psalm remembers previous array key assertion even if array is replaced
Thought it was a bug in my immutable refactoring, turns out it's also present upstream: https://psalm.dev/r/05f744e632
I found these snippets:
https://psalm.dev/r/05f744e632
<?php
$dummy = ['test' => ''];
$a = ['test' => null];
if ($a['test'] === null) {
$a = $dummy;
}
$var = $a['test'];
/** @psalm-trace $var */;
Psalm output (using commit 4b2935f):
INFO: Trace - 11:25 - $var: null
INFO: UnusedVariable - 3:1 - $dummy is never referenced or the value is not used
INFO: UnusedVariable - 8:5 - $a is never referenced or the value is not used
INFO: UnusedVariable - 10:1 - $var is never referenced or the value is not used
Broken by https://github.com/vimeo/psalm/commit/d7d9ddc653b7d292970baa9f6de2bf43b7db57ef#
Pinging @muglug :)