-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
sorry, it seems this PR should be filed to branch 4.4 |
failed tests😭, so hard to make a pull request, but problem indeed exists |
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? |
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? |
If we don't configure a method name,
It's about allowing a less surprising method name, I'd say. |
Ref #41876 |
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
Outdated
Show resolved
Hide resolved
src/Symfony/Component/EventDispatcher/Tests/DependencyInjection/RegisterListenersPassTest.php
Outdated
Show resolved
Hide resolved
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 at every 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
@@ -81,7 +81,7 @@ public function process(ContainerBuilder $container) | ||
|
||
if (!isset($event['method'])) { | ||
$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 from https://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
when do some breakpoint debugging in my project. |
please apply the code style fix from fabbot |
Thank you @jjsty1e. |
@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
method
key 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.