-
-
Notifications
You must be signed in to change notification settings - Fork 934
Closed
Closed
Copy link
Labels
Milestone
Description
Bug report
Code snippet that reproduces the problem
https://phpstan.org/r/c03dea3a-c5d2-4fa7-85e5-2e58f5f43cd1
Error message:
Cannot access property $someArray on PropertyClass|null.
Expected output
No phpstan error. Null coalesce already properly handles nested nulls, and array access to missing keys properly. There is no ambiguity in the code, no dynamic properties are being used so this should be properly handled by phpstan.
Interesting note: If you remove |null from the @var notation then no phpstan error is thrown. It seems to be only triggered when $property can also be null.
Also, if $someArray happened to be something other than an array (like string|null) it would also properly work and phpstan would throw no error.