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
FP: is_subclass_of() with non-empty-string #5369
Comments
@voku After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
- 9: Call to function is_subclass_of() with non-empty-string and 'BrandBase' will always evaluate to false.
+-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
|
@voku After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-9: Call to function is_subclass_of() with non-empty-string and 'BrandBase' will always evaluate to false.
+6: Method BrandLib::getBrandObjectBySkinname() should return BrandBase|null but return statement is missing. Full report
|
I did some testing with commits from around the time this stopped working, and phpstan/phpstan-src@1283db7 was the commit where the change occurred (the commit right before that one reported no problems for the example snippet). Looking at it and reverting some of the changes from that commit individually, I was able to determine that the cause is this addition around line 1049 of src/Analyser/MutatingScope.php: if ($leftStringType->isNonEmptyString()->or($rightStringType->isNonEmptyString())->yes()) {
return new IntersectionType([
new StringType(),
new AccessoryNonEmptyStringType(),
]);
} I'm not sure what the right change would be, though, since I'm not particularly familiar with PHPStan's code. |
@voku After the latest commit in dev-master, PHPStan now reports different result with your code snippet: @@ @@
-9: Call to function is_subclass_of() with non-empty-string and 'BrandBase' will always evaluate to false.
+No errors |
Fixed: phpstan/phpstan-src@73f14db |
Closes phpstan/phpstan#5893 Closes phpstan/phpstan#6070 Closes phpstan/phpstan#5869 Closes phpstan/phpstan#6212 Closes phpstan/phpstan#6262 Closes phpstan/phpstan#6266 Closes phpstan/phpstan#6023 Closes phpstan/phpstan#6108 Closes phpstan/phpstan#6020 Closes phpstan/phpstan#1746 Closes phpstan/phpstan#1516 Closes phpstan/phpstan#6174 Closes phpstan/phpstan#6112 Closes phpstan/phpstan#5749 Closes phpstan/phpstan#5969 Closes phpstan/phpstan#5295 Closes phpstan/phpstan#5675 Closes phpstan/phpstan#5369 Closes phpstan/phpstan#6699 Closes phpstan/phpstan#6505
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
Code snippet that reproduces the problem
https://phpstan.org/r/e24cf39e-68f1-4c66-b1be-0c39189b721a
Expected output
no error because it's maybe true or false
Did PHPStan help you today? Did it make you happy in any way?
It improves the code quality step by step, and that is what good progress looks like. 🥇
The text was updated successfully, but these errors were encountered: