You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey, I am updating a symfony project with rector and I so much love it! Thanks for this amazing tool :)
I am almost done, only SYMFONY_CODE_QUALITY is missing.
But in Symfony 6.4 upwards we also have the #[AsEventListener] Attribute, which not only makes the "no config" argument obsolete, but also allows to target methods, so you can add multiple Listeners to the same method for different events, or have multiple handler methods in one class etc.
There is really no reason anymore to change to EventSubscriber then, or am I wrong?
Wouldn't it be better and more modern to have a EventSubscriberToAsEventListenerAttributeRector and a EventListenerToAsEventListenerAttributeRector instead? Or at least make it aware of that attribute and don't run that rector in that case?
Thanks in advance for your answers <3
The text was updated successfully, but these errors were encountered:
Wasn't sure if that will work, since IDE is complaining about same class names in the same file, but apparently we don't want Rector to change them in those cases, correct? :)
Question
Hey, I am updating a symfony project with rector and I so much love it! Thanks for this amazing tool :)
I am almost done, only
SYMFONY_CODE_QUALITY
is missing.Rector always trys to convert
EventListeners
toEventSubscribers
even if I use the Attribute and I wondered why.I found this blog about it: https://tomasvotruba.com/blog/2019/07/22/how-to-convert-listeners-to-subscribers-and-reduce-your-configs/
But in Symfony 6.4 upwards we also have the
#[AsEventListener]
Attribute, which not only makes the "no config" argument obsolete, but also allows to target methods, so you can add multiple Listeners to the same method for different events, or have multiple handler methods in one class etc.There is really no reason anymore to change to EventSubscriber then, or am I wrong?
Wouldn't it be better and more modern to have a
EventSubscriberToAsEventListenerAttributeRector
and aEventListenerToAsEventListenerAttributeRector
instead? Or at least make it aware of that attribute and don't run that rector in that case?Thanks in advance for your answers <3
The text was updated successfully, but these errors were encountered: