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
Strict comparison using === between 4 and 4 will always evaluate to true. #4242
Comments
The
|
Both of the examples should report an error. Here are the inferred types: https://phpstan.org/r/74a325e0-0502-44d8-b536-5b348d14ec97 I don't know why the in_array() call on line 105 does not report an error, but it should. If you're not interested in "always true" errors, you can turn them off. Either by stopping using phpstan-strict-rules, or by setting these settings off: https://phpstan.org/config-reference#checkalwaystruechecktypefunctioncall |
@ondrejmirtes Can you please provide more details on why both cases should report an error and how it works? I believe there is no always true condition. The |
@SergeC The method is annotated as |
@SergeC After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-62: Strict comparison using === between 4 and 4 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 Full report
|
@ondrejmirtes After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
- 53: Dumped type: 1|2|3|4|7|8|9|100
- 63: Strict comparison using === between 4 and 4 will always evaluate to true.
- 86: Dumped type: 1|2|3|4|7|8|9|100
-103: Dumped type: 7|8|9|100
+ -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 Full report
|
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
I have a code in my project like in
case1
in a code sample which triggers the following error. Incase2
is the same code snippet with sortedelseif
branches.Code snippet that reproduces the problem
https://phpstan.org/r/1b70ab7b-24e9-4507-bb77-c175607bf78f
Expected output
The
case1
example must work without an error.The text was updated successfully, but these errors were encountered: