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
in_array with possible missing values throws "will always evaluate to true" in strict mode #3892
Comments
@faizanakram99 After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 7.4 – 8.0 (1 error)
==========
-63: Call to function in_array() with arguments 'ReceiptOrder', array<0|1, 'PickingOrder'|'ReceiptOrder'> and true will always evaluate to true.
+-1: Internal error: PHPStan\Rules\Methods\WrongCaseOfInheritedMethodRule::findMethod(): Argument #2 ($classReflection) must be of type PHPStan\Reflection\ClassReflection, null given, called in /var/task/vendor/phpstan/phpstan-strict-rules/src/Rules/Methods/WrongCaseOfInheritedMethodRule.php on line 40
+Run PHPStan with --debug option and post the stack trace to:
+https://github.com/phpstan/phpstan/issues/new?template=Bug_report.md
PHP 7.1 – 7.3 (3 errors)
========== Full reportPHP 7.4 – 8.0 (1 error)
PHP 7.1 – 7.3 (3 errors)
|
@faizanakram99 After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
PHP 7.1 – 7.3 (3 errors)
==========
-60: Syntax error, unexpected ',' on line 60
+60: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 60
60: Syntax error, unexpected T_DOUBLE_ARROW on line 60
-60: Syntax error, unexpected T_STRING, expecting T_PAAMAYIM_NEKUDOTAYIM on line 60
+60: Syntax error, unexpected ',' on line 60 Full reportPHP 7.4 – 8.0 (1 error)
PHP 7.1 – 7.3 (3 errors)
|
@faizanakram99 After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-PHP 7.4 – 8.0 (1 error)
+PHP 7.4 – 8.0
==========
-63: Call to function in_array() with arguments 'ReceiptOrder', array<0|1, 'PickingOrder'|'ReceiptOrder'> and true will always evaluate to true.
+No errors
PHP 7.1 – 7.3 (3 errors)
========== Full reportPHP 7.4 – 8.0No errors PHP 7.1 – 7.3 (3 errors)
|
Fixed: phpstan/phpstan-src@4321374 |
Closes phpstan/phpstan#5759 Closes phpstan/phpstan#5668 Closes phpstan/phpstan#5496 Closes phpstan/phpstan#4666 Closes phpstan/phpstan#3892 Closes phpstan/phpstan#3314 Closes phpstan/phpstan#2870 Closes phpstan/phpstan#5354
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. |
Bug report
This code snip will not always be true as
OrderSaved::$dtos
might not containReceiptOrder
sinceReceiptOrder::fromOrder()
can return nullCode snippet that reproduces the problem
https://phpstan.org/r/7b6a301e-f874-4dce-bcd5-1c54cd42e854
Expected output
No errors
The text was updated successfully, but these errors were encountered: