vimeo / psalm

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

Associative array destructuring warns with nullable array #10076

Open M393 opened 1 year ago

M393 commented 1 year ago

https://psalm.dev/r/48d4c1473e

I'd expect no warning here, as the code works fine. If the returned value is null $x will be null.

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

I found these snippets:

https://psalm.dev/r/48d4c1473e ```php $_x] = f1(); /** @return list{int}|null */ function f2(): ?array { return null; } [$_x] = f2(); ``` ``` Psalm output (using commit 73ebe22): ERROR: PossiblyNullArrayAccess - 7:8 - Cannot access array value on null variable ```