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

Comparison operation ">" between (int<min, X>|int<Y, max>|string) and Z is always true. #5295

Closed
neanton opened this issue Jul 13, 2021 · 4 comments
Labels
Milestone

Comments

@neanton
Copy link

neanton commented Jul 13, 2021

Bug report

The following snippet produces this error:

Comparison operation ">" between (int<min, 4>|int<11, max>|string) and 10 is always true.

Seems like the problem is caused by mixed array key. Type hinting array returned from getValue function to <int, int> suppresses the warning.

Code snippet that reproduces the problem

https://phpstan.org/r/e9007c26-e626-49e5-aa97-469e860ea8ea

Expected output

No error should be thrown

@ondrejmirtes ondrejmirtes added this to the Easy fixes milestone Jul 13, 2021
@phpstan-bot
Copy link
Contributor

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

@@ @@
- 9: Comparison operation ">" between (int<min, 4>|int<11, max>|string) and 10 is always true.
-18: Method Demo::getValue() return type has no value type specified in iterable type array.
+18: Method Demo::getValue() return type has no value type specified in iterable type array.
+18: Method Demo::getValue() should return array but return statement is missing.
Full report
Line Error
18 Method Demo::getValue() return type has no value type specified in iterable type array.
18 Method Demo::getValue() should return array but return statement is missing.

@phpstan-bot
Copy link
Contributor

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

@@ @@
- 9: Comparison operation ">" between (int<min, 4>|int<11, max>|string) and 10 is always true.
 18: Method Demo::getValue() return type has no value type specified in iterable type array.
Full report
Line Error
18 Method Demo::getValue() return type has no value type specified in iterable type array.

@ondrejmirtes
Copy link
Member

Fixed: phpstan/phpstan-src@dd5633f

@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 Mar 31, 2022
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

3 participants