-
Notifications
You must be signed in to change notification settings - Fork 659
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
Improve inferring the "final" static
type when calling static methods inside a different class
#8249
Conversation
… static methods inside a different class differentiate between `static` defined in a class which CALLS a given static method, and `static` defined in the method which IS CALLED.
...ternal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
Outdated
Show resolved
Hide resolved
It looks like ClassTest has some other static stuff like |
...ternal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
Outdated
Show resolved
Hide resolved
…Type() for non-object cases
…xistingAtomicStaticCallAnalyzer::getMethodReturnType()
...ternal/Analyzer/Statements/Expression/Call/StaticMethod/ExistingAtomicStaticCallAnalyzer.php
Outdated
Show resolved
Hide resolved
meh, when moving test cases I added them to "invalid code" section instead of "valid code" |
Please indent the test code one level past the |
Thanks! |
fixes #8200
After some insane debugging and trying to wrap my head around it, I found the reason it behaves improperly.
When calling a static method of some class, there are two possibilities:
@return Collection<static>
, that meansstatic
is defined by the static method which we are calling.@return Collection<T>
, but the class which CALLS it can have something like@return Collection<static>
. Sostatic
is defined by the CALLING code, not the CALLED. In this case, Psalm behaved incorrectly, because it always assumed only the 1st case.I have to move the test case somewhere (for now it's a separate class), please give a hint.