Skip to content
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

Make ReflectionAttribute generic #640

Merged
merged 3 commits into from Aug 24, 2021
Merged

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
2 participants