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

False positive when 10 conditions are joined by '||' in if. #3366

Closed
tekezo opened this issue May 30, 2020 · 8 comments
Closed

False positive when 10 conditions are joined by '||' in if. #3366

tekezo opened this issue May 30, 2020 · 8 comments
Labels

Comments

@tekezo
Copy link

tekezo commented May 30, 2020

Bug report

The following error is reported if 10 conditions are joined by '||' in if.

Strict comparison using === between *NEVER* and 'XXX' will always evaluate to false.

Code snippet that reproduces the problem

https://phpstan.org/r/4d8f632c-d4fc-4cc6-b9e2-ae81db46b548

There are no problem until 9 conditions.
https://phpstan.org/r/0f595079-d3a0-4fd1-aa2a-af28d9068fda

@xPaw
Copy link

xPaw commented Aug 12, 2020

Happened in my code base too.

https://phpstan.org/r/a87dab63-efd1-4783-8c85-89ed46b630fc

@phpstan-bot
Copy link
Contributor

@tekezo After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-14: Strict comparison using === between *NEVER* and '0' will always evaluate to false.
+No errors

@phpstan-bot
Copy link
Contributor

@xPaw After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-14: Strict comparison using === between *NEVER* and 'j' will always evaluate to false.
-15: Strict comparison using === between *NEVER* and 'k' will always evaluate to false.
-16: Strict comparison using === between *NEVER* and 'l' will always evaluate to false.
-17: Strict comparison using === between *NEVER* and 'm' will always evaluate to false.
-18: Strict comparison using === between *NEVER* and 'o' will always evaluate to false.
-19: Strict comparison using === between *NEVER* and 'p' will always evaluate to false.
+No errors

@tekezo
Copy link
Author

tekezo commented Jul 14, 2021

Thanks!

@tekezo tekezo closed this as completed Jul 14, 2021
@ondrejmirtes ondrejmirtes reopened this Jul 14, 2021
@ondrejmirtes
Copy link
Member

This isn't fully fixed, you can still break it by introducing an empty string into the mix: https://phpstan.org/r/d98133e1-9091-4c05-9126-4951aeef8a63

@phpstan-bot
Copy link
Contributor

@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet:

@@ @@
-15: Strict comparison using === between *NEVER* and '0' will always evaluate to false.
+No errors

@ondrejmirtes
Copy link
Member

I managed to solve this.

Look forward to the next release (0.12.95) :)

@github-actions
Copy link

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 Sep 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants