We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
https://phpstan.org/r/2a2c7b0c-c410-40ff-b2a5-d6c8036f3780
Expected output in these cases is that return value is positive integer. So no error will be reported.
The text was updated successfully, but these errors were encountered:
Needs to be adjusted in https://github.com/phpstan/phpstan-src/blob/master/src/Type/Php/MinMaxFunctionReturnTypeExtension.php.
Sorry, something went wrong.
@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
Dumped type: int
Implemented: phpstan/phpstan-src@458f5d2
Regression tests
3c41113
Ref phpstan/phpstan#4793 Ref phpstan/phpstan#5062 Ref phpstan/phpstan#5447 Ref phpstan/phpstan#5454 Ref phpstan/phpstan#3366 Ref phpstan/phpstan#5072 Ref phpstan/phpstan#3530 Ref phpstan/phpstan#5530 Ref phpstan/phpstan#1861 Ref phpstan/phpstan#4843 Ref phpstan/phpstan#4602 Ref phpstan/phpstan#4499 Ref phpstan/phpstan#2142
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.
No branches or pull requests
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.
The text was updated successfully, but these errors were encountered: