Skip to content

Conversation

@vhenzl
Copy link
Contributor

@vhenzl vhenzl commented Aug 24, 2021

Resolves phpstan/phpstan#5511.

I used an extension from phpstan-doctrine as an exemple for the implementation of ReflectionClassGetAttributesMethodReturnTypeExtension on but I'm not sure if it's correct as it allows for return types like array<ReflectionAttribute<some random string>>.

@vhenzl
Copy link
Contributor Author

vhenzl commented Aug 24, 2021

How do I exclude the code for PHP < 8?

Edit: I figured I have to add a runtime stub for ReflectionAttribute.

@ondrejmirtes ondrejmirtes merged commit 4c4a9bf into phpstan:master Aug 24, 2021
@ondrejmirtes
Copy link
Member

This is almost perfect, thank you! :)

@vhenzl
Copy link
Contributor Author

vhenzl commented Aug 24, 2021

Oh no, I totally missed out getAttributes() on other Reflection classes :(

@ondrejmirtes, since there isn't any common abstraction for reflection classes with getAttributes() and getClass() of the extension interface allows only one class, I should make the existing implementation abstract and then add an extension per each reflection class. Is that correct?

@ondrejmirtes
Copy link
Member

@vhenzl It's not. You should make whatever needs to be configurable through the extension constructor, then register it multiple times in .neon.

@vhenzl
Copy link
Contributor Author

vhenzl commented Aug 24, 2021

Right, makes sense. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for generics in ReflectionAttribute

2 participants