Detect unused method call on a separate line with possibly pure method#3022
Detect unused method call on a separate line with possibly pure method#3022ondrejmirtes merged 8 commits intophpstan:1.11.xfrom
Conversation
src/Rules/DeadCode/CallToMethodStatementWithoutImpurePointsRule.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Skip if method is not final. Child class (polymorphic call) might have side effects.
There was a problem hiding this comment.
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