-
Notifications
You must be signed in to change notification settings - Fork 471
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 resolution of generic @method tags #2931
Conversation
Thi has something to do with NameScope (which contains information about what T refers to in PHPDoc) and might not be actually trivial to fix, I'll think about it 😊 |
fab3208
to
f94b1df
Compare
f94b1df
to
8e2967e
Compare
This pull request has been marked as ready for review. |
I think I did it right. |
ah nice! beat me to it, was just finishing breakfast and then going to take a look at this |
Anyway, there's a very similar feature request - to do the same thing for callables and Closures. So first we need to finish phpstan/phpdoc-parser#199 and then to a very similar PR in phpstan-src to this one. |
Thank you! |
Nice! |
I just realized we're missing some rules about this. Basically the equivalents of these: https://phpstan.org/r/ca12c484-b4f1-4e5b-a418-3069ec569411 The best way to implement them is to create a new rule similar to https://github.com/phpstan/phpstan-src/blob/1.11.x/src/Rules/Generics/MethodTemplateTypeRule.php#L78 that also calls TemplateTypeCheck. Do you have time to implement this? Thanks .) |
Attempt to close: phpstan/phpstan#6371 (comment)
This is as far as i've managed to get today on this issue; thanks to your help i've managed to forward the
TemplateTag
s through and correctly build the template type map, but now i can't get it to resolve the return types correctly 😅The output i'm getting from the test is:
i suspect it's because the
$returnType
passed toAnnotationMethodReflection
is resolved with only the class-level templates and not both class and method level templates inTemplateTypeHelper::resolveTemplateTypes
.resolveTemplateTypes()
is returning anObjectType()
which seems incorrect, but i'm not sure what it's supposed to be to cause it to be templated properly.To resolve this i've tried:
$classReflection->getActiveTemplateTypeMap()
and my generated$templateTypeMap
before passing it in toresolveTemplateTypes()
TemplateTypeHelper::resolveTemplateTypes
, as i suspected it may be resolving too soon?Sorry to keep asking, but is there any further pointers you have for me? Thanks.