-
Notifications
You must be signed in to change notification settings - Fork 651
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
str split return non empty #6324
Conversation
66234e3
to
bfc48a4
Compare
bfc48a4
to
1cdad83
Compare
In the 8.0 delta, the old version for And it looks like that change for The |
Also, for this reason, values of zero or lower are allowed in older versions (7.4 and before). That's when it will return false. While this is probably unwanted behaviour, it is legal code. So I would only add the positive-int requirement to PHP 8 and later. |
Is that for the case when an invalid encoding was passed?
That's because it returned |
It generates warnings (https://3v4l.org/FMlWJ), so I wouldn't call that legal code. |
@VincentLanglet given that |
But by omitting the
Fair enough, it won't hurt if Psalm warns people of wrong inputs. |
You don't need the falsey check if you pass a positive-int. But I agree we could create such issues by removing the
What about |
Point is, the function CAN return false, so a programmer should be able to check for it without needing I don't think a static analyzer should mark boilerplate code as incorrect, unless it absolutely is (as it is from PHP 8.0 onward). |
@bitwise-operators I'm making this PR because I'm calling
is not a forbidden call. It emits a warning and return But psalm decided to use
So the decision has already been taken long time ago and should be on the |
We don't want to end up in a situation where we both require to pass |
Thanks! |
Since str_split('', 42) is [0 => ''], I think the list is never empty.