You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When accessing annotated array it is possible to get null as a result when the key is undefined.
Currently no error is emitted and even checking if result is null is considered as an error (comparsion is always false).
(Sorry if duplicate, I really tried to search hard this time. This might be related #3126 )
Hi, this isn't considered because you should check that the key exists using array_key_exists or isset. Accessing an undefined array key generates a warning, you should log notices and warnings in production and fix them so that your error logs are clean.
Bug report
When accessing annotated array it is possible to get
null
as a result when the key is undefined.Currently no error is emitted and even checking if result is
null
is considered as an error (comparsion is always false).(Sorry if duplicate, I really tried to search hard this time. This might be related #3126 )
Code snippet that reproduces the problem
https://phpstan.org/r/aedb5786-c0ba-4fc8-b311-f2a1c150f6c8
Expected output
Phpstan should treat accessing array by index as possible null.
The text was updated successfully, but these errors were encountered: