Replies: 1 comment
-
Seems like a case where the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
https://psalm.dev/r/b5c9862354
In the given example we are wanting to search for an instance of a string in a list and unset it. However due to PHP's type coercion we accidentally unset the first element in our list instead because
array_search
returnsfalse
, and unsettingfalse
coerces to0
.As far as I see Psalm isn't flagging anything here.
I believe Psalm should be able to flag if a potential boolean value is used as an array key as some form of error - bool false is never an appropriate array-key - if somebody wishes to use potential
false
as an array key they should type cast it (e.g.'false'
would be a legitimate array key, as would0
)Beta Was this translation helpful? Give feedback.
All reactions