-
-
Notifications
You must be signed in to change notification settings - Fork 946
Description
Bug report
PHPStan incorrectly resolves the return type of a static method annotated with @return static<T> to the parent class when called from a child class, and proceeds to report "undefined method" for every subsequent call to a method of the child class.
Using @return static resolves the issue but prevents propagation of type information.
Code snippet that reproduces the problem
https://phpstan.org/r/b4f91405-36ef-463e-bc84-9050eec247ff
Expected output
In the context of a child class with no templated types, static<T> would be invalid, and while handling this scenario robustly may be non-trivial, PHPStan should resolve static<T> correctly in the context of a child class that does specify a templated type. If not, it should report unsupported syntax and/or advise using static, because silently treating it as self<T> results in false negatives.
Did PHPStan help you today? Did it make you happy in any way?
While updating a codebase with generics as first-class citizens (now that I'm using a vscode extension that understands them), I've been very happy with PHPStan's excellent support for scenarios I thought it would struggle with. Thank you for your service!