vimeo / psalm

A static analysis tool for finding errors in PHP applications
https://psalm.dev
MIT License
5.57k stars 660 forks source link

Isset check is breaking the array-shape definition #9500

Open VincentLanglet opened 1 year ago

VincentLanglet commented 1 year ago

https://psalm.dev/r/18d1dfabd5

After the isset check, every values are considered as mixed by psalm.

psalm-github-bot[bot] commented 1 year ago

I found these snippets:

https://psalm.dev/r/18d1dfabd5 ```php $i */ function foo(array $i) { /** @psalm-trace $a */ $a = $i; if (isset($i['type'])) { } /** @psalm-trace $a */ $a = $i; } ``` ``` Psalm output (using commit 902a019): INFO: Trace - 11:5 - $a: array{label?: false|null|string, type?: string, ...} INFO: Trace - 17:5 - $a: array{label?: false|mixed|null|string, type?: mixed|string, ...} INFO: UnusedVariable - 11:5 - $a is never referenced or the value is not used INFO: UnusedVariable - 17:5 - $a is never referenced or the value is not used INFO: MissingReturnType - 9:10 - Method foo does not have a return type, expecting void ```