Skip to content
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

Type not detected correctly when using strlen + null-coalesce operator to check variable #7949

Closed
levu42 opened this issue Sep 6, 2022 · 1 comment · Fixed by phpstan/phpstan-src#1707
Labels
Milestone

Comments

@levu42
Copy link

levu42 commented Sep 6, 2022

Bug report

Using strlen($nullableString ?? '') > 0 to figure out if a string is null / non-null doesn't get parsed correctly.

Code snippet that reproduces the problem

https://phpstan.org/r/dd783d15-3723-4c3b-8b78-8c756345e92a

Expected output

I expect PHPStan to recognize in my example $price can not be null on the function call.

Did PHPStan help you today? Did it make you happy in any way?

Thank you for your amazing work! Since using PHPStan I don't commit any stupid bugs anymore, only the clever ones, which makes debugging way more fun :)

@github-actions
Copy link

github-actions bot commented Oct 8, 2022

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants