Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[EventDispatcher] Correct the called event listener method case#41905
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
jjsty1e commentedJun 29, 2021
sorry, it seems this PR should be filed to branch 4.4 |
jjsty1e commentedJun 30, 2021
failed tests😭, so hard to make a pull request, but problem indeed exists |
derrabus commentedJun 30, 2021
The current behavior might be somewhat unexpected. But if we just change it, we will break existing applications. Can we make it so that both ways work? |
fabpot commentedJun 30, 2021
Method names are case insentitive in PHP, right? So, is there a bug that needs to fix here or is it just for a better looking method name? |
derrabus commentedJun 30, 2021
If we don't configure a method name,
It's about allowing a less surprising method name, I'd say. |
ro0NL commentedJun 30, 2021
Ref#41876 |
ro0NL left a comment
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.
src/Symfony/Component/EventDispatcher/DependencyInjection/RegisterListenersPass.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php OutdatedShow resolvedHide resolved
Uh oh!
There was an error while loading.Please reload this page.
ro0NL left a comment
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.
i tend to believe it's a bugfix (as method calls are case-insensitive). Camel casing atevery word boundary, but not_, feels odd
ppl relying on case-sensitive method calls in DI config (which now changes) rely on implementation details IMHO. But 5.x would be as fine i guess 👍
@jjsty1e how did you discovered this? :D
| $event['method'] ='on'.preg_replace_callback([ | ||
| '/(?<=\b)[a-z]/i', | ||
| '/(?<=\b|_)[a-z]/i', | ||
| '/[^a-z0-9]/i', |
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.
btw this 2nd regex is a leftover fromhttps://github.com/symfony/symfony/pull/1162/files it seems, where it was replaced with empty string which now happens at L87, this happened with refactoring likely.
AFAIK it's redundant 👼
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.
it confused me too, but I'm not sure we can remove
jjsty1e commentedJul 3, 2021
when do some breakpoint debugging in my project. |
nicolas-grekas commentedJul 3, 2021
please apply the code style fix from fabbot |
fabpot commentedJul 4, 2021
Thank you@jjsty1e. |
jjsty1e commentedJul 4, 2021
@fabpot my pleasure😀 |
when define an event listener, if you don't specify a method, then the word case of the actual method maybe wrong, for example :
no
methodkey at this tag, then actual method called isonKernelControllerarguments, actually it should beonKernelControllerArguments, the case of word 'arguments' should be upper.ps: only event name that has dash(
_) will be affected.