-
Notifications
You must be signed in to change notification settings - Fork 504
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
Detect unused method call on a separate line with possibly pure method #3022
Conversation
} | ||
|
||
$classType = $scope->getType($node->expr->var); | ||
foreach ($classType->getObjectClassReflections() as $classReflection) { |
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.
Please use $scope->getMethodReflection()
instead of all of this.
UnionTypeMethodReflection returns $this->methods[0]->getDeclaringClass()
as declaring class but we can solve that later. Thanks.
} | ||
|
||
$methodReflection = $classReflection->getMethod($methodName, $scope); | ||
if (!$methodReflection->isPure()->maybe()) { |
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.
Skip if method is not final. Child class (polymorphic call) might have side effects.
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 method is not final, it's sufficient that $classReflection
is final. Also please write test cases for these.
This pull request has been marked as ready for review. |
I cannot reproduce the stale-result-cache errors locally. remaining build errors seem unrelated |
… final, but the callee class might
FYI I added a commit 024c32a - I think these cases can be reported as well |
(FYI We won't need to care about finality for StaticCall as we know exactly the class+method we're calling, there's no polymorphism at hand.) |
Thank you! |
similar to 281a87d