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
Add generic support to @method
definitions
#6371
Comments
Thank you for your kind words! :) This isn't hard to implement, the main work needs to be done in https://github.com/phpstan/phpdoc-parser Don't forget to also support bounds like: After that's done and released, it's really easy to propagate that info here, right now the "template type map" in |
@allejo After the latest push in 1.9.x, PHPStan now reports different result with your code snippet: @@ @@
-10: PHPDoc tag @method has invalid value (bool compare<T, K>(T $t, K $k) Compares two objects magically somehow): Unexpected token "<", expected '(' at offset 60
-18: Call to an undefined method HelloWorld<mixed, mixed>::compare().
+No errors |
This isn't fully implemented yet, only in phpdoc-parser. |
@ondrejmirtes i've been trying to implement this and have been struggling unfortunately; i think i lack some understanding of what the would that be resolved and passed in here? i've tried looking around the codebase to see if there are any examples similar to what i'm trying to implement, but i can't seem to find anything despite knowing there must be one, so even just pointing at that could be a big help, thanks for your time |
FunctionVariant has two template type maps: the "original declaration" one and the "resolved" one. You should only put in the "original declaration" one that basically represents how The "resolved" template type map can stay I think that once you convert the |
and just to confirm, in |
No, the You can look for example at |
Implemented: phpstan/phpstan-src#2931 FYI @allejo Your example didn't even require generics support for |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Feature request
Would it be possible to add generic support to functions that are defined via
@method
docs?https://phpstan.org/r/1da86817-e322-401b-938d-6272e51d85e0
Did PHPStan help you today? Did it make you happy in any way?
Yes! It's helped me a lot with avoiding errors in my projects because I would mess up types. Especially generic support, which is incredibly useful ❤️
The text was updated successfully, but these errors were encountered: