Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.6k
[TypeInfo] AddPhpDocAwareReflectionTypeResolver
#57618
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
PhpDocAwareReflectionTypeResolver
src/Symfony/Component/TypeInfo/TypeResolver/PhpDocAwareReflectionTypeResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/TypeInfo/TypeResolver/PhpDocAwareReflectionTypeResolver.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
with minor comments
Isn't this outside the scope of TypeInfo and exactly the scope for the PropertyType component? Or what is the difference between these 2 components if TypeInfo is also going to read type information from different sources outside of PHP's native types? |
TypeInfo is about getting the type of any PHP element including class properties but also methods, functions and their parameters. It does it by reading through the most common sources that are built-in types but also docblocks until we don't need them anymore for types. |
To illustrate more, this change unlocks making |
00d8043
to10fc1c4
Compare10fc1c4
to57a5c8a
Compare57a5c8a
toc6698ce
Comparesrc/Symfony/Component/TypeInfo/TypeResolver/PhpDocAwareReflectionTypeResolver.phpShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Looks awesome and makes phpDoc handling way easier !
I tried to make a phpDoc example from scratch here:symfony/symfony-docs#20014 (comment) (see "Then we extract the phpDoc we want to parse" part), it is very complex without such wrapper !
chalasr commentedJul 22, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Unless I'm mistaken the build failure should disappear once merged in 7.2 and is due to 7.2.x-dev being installed as part of property-info's test suite, while this breaks BC in the experimental TypeInfo. |
Thank you@mtarld. |
0234e05
intosymfony:7.2Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Add a
PhpDocAwareReflectionTypeResolver
that resolves type on reflections prioritizing PHP documentation.The same feature already exists in the
PropertyInfo
component and improves DX a lot.Installing
phpstan/phpdoc-parser
automatically enables this feature both using the type-info component standalone and the fullstack framework.