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

min/max functions cannot resolve final value range if one of values is variable or constant #5072

Closed
lulco opened this issue May 26, 2021 · 4 comments

Comments

@lulco
Copy link

lulco commented May 26, 2021

Bug report

min/max functions cannot resolve final value range if one of values is variable or constant

Code snippet that reproduces the problem

https://phpstan.org/r/2a2c7b0c-c410-40ff-b2a5-d6c8036f3780

Expected output

Expected output in these cases is that return value is positive integer. So no error will be reported.

@ondrejmirtes
Copy link
Member

@phpstan-bot
Copy link
Contributor

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

@@ @@
 20: Dumped type: int
-21: Method HelloWorld::incorrect() should return int<1, max> but returns int.
-29: Dumped type: int
-30: Method HelloWorld::incorrectWithConstant() should return int<1, max> but returns int.
+29: Dumped type: int
Full report
Line Error
20 Dumped type: int
29 Dumped type: int

@ondrejmirtes
Copy link
Member

Implemented: phpstan/phpstan-src@458f5d2

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

No branches or pull requests

3 participants