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
[HttpKernel] Add optional $className
param to ControllerEvent::getAttributes()
#50335
Conversation
Is this really worth it? -$attributes = $event->getAttributes(SomeAttribute::class);
+$attributes = $event->getAttributes()[SomeAttribute::class] ?? null; |
@nicolas-grekas the difference is that the new argument has a generic signature, telling SA tools that all returned objects are an instance of the provided class name. |
Wouldn't this work? |
@nicolas-grekas no. This won't work as it would force using the same That's precisely why Psalm introduced a |
d25e6fb
to
c4f4012
Compare
c4f4012
to
a45cc65
Compare
Thank you @HypeMC. |
A minor DX improvement since most of the time only one type of attribute is needed, eg: