-
Notifications
You must be signed in to change notification settings - Fork 502
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
Fix ImpossibleCheckTypeFunctionCallRule for is_subclass_of
and is_a
#3404
Conversation
Changing the rule is not going to help you against "Result of && is always false.". I'd much rather change the logic in IsSubclassOfFunctionTypeSpecifyingExtension. |
591e804
to
10eb37a
Compare
is_subclass_of
is_subclass_of
and is_a
8704421
to
8443ae3
Compare
@@ -1133,9 +1133,7 @@ public function dataCondition(): iterable | |||
new Arg(new Variable('stringOrNull')), | |||
new Arg(new Expr\ConstFetch(new Name('false'))), | |||
]), | |||
[ | |||
'$object' => 'object', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (is_subclass_of($object, $stringOrNull, false))
specified $object
as object
but this was already known so it's not a big loss.
8443ae3
to
8d67889
Compare
This pull request has been marked as ready for review. |
I think it was possible indeed, I get something working. |
Friendly ping @ondrejmirtes ; this PR is ready to be re-reviewed :) |
Thank you. |
Unfortunately I have to revert this. it leads to false positives like: https://phpstan.org/r/5941cd95-26d7-49cf-a2e0-ffc21c4a7697 |
No problem, I'll try to improve the idea in #3788 |
Closes phpstan/phpstan#3979
which can be simplified to https://phpstan.org/r/ef72a996-8fbe-4a4e-831f-4d78c542ad19
I'm not sure there is a better (easy ?) fix for this issue.
is_subclass_of($string, $bar)
specify the type of$string
to class-string when true, but it doesn't mean that the call is useless if the param is already a class-string.I discovered there was an exclusion of
is_a
in theImpossibleCheckTypeFunctionCallRule
(maybe for the same reason)so I think it could be the same for
is_subclass_of
since the behavior is similar.