-
-
Notifications
You must be signed in to change notification settings - Fork 864
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
strtok is never false when called with both the string and the token #3981
Comments
If |
Thanks for the info, i guess that explains the false return type. Not sure if string length can be checked statically anyways so i think the typing is perfectly alright, this issue can be closed unless some one else has a different opinion on it |
So if I get it correctly, |
Hmm, which functions would return this new type |
There's going to be multiple ways to produce
Without these, the |
Aha, thanks for the explanation, so this narrows down the type after certain checks which is great. I see php-stan recently added |
Implemented by: phpstan/phpstan-src@6ef5e91 |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Just want to confirm this is correct, before creating a pr:
So
strtok
returns false only it reaches the end of the string and there are no more tokens to extract likeBut phpstan considers
strtok($a, " ")
to also returnfalse|string
even though its only when called without first argument that it can return false. Is there a way to model this function correctly with phpstan's types?https://phpstan.org/r/abe8c204-911c-477e-bceb-8854d19ce4dc
The text was updated successfully, but these errors were encountered: