Bug report
This issue is directly related to phpstan/phpstan-strict-rules#135, which is actually the main issue for us.
The logic introduced in phpstan/phpstan-src@75d00c9
always removes NULL value from the final type in case of null-safe access.
That makes sense for some rules like CallMethodsRule but in cases that care about the actual return value, this assumption is wrong.
Code snippet that reproduces the problem
https://phpstan.org/r/82a28570-e464-4010-91a0-683a22605bb8
Expected output
Cannot use array destructuring on null.
Did PHPStan help you today? Did it make you happy in any way?
😍 PHPStan is awesome! Can't imagine using PHP without static type checking.