Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[EventDispatcher] Improve method resolving when it is omitted in tag #50783

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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
Loading
from

Conversation

nikophil
Copy link
Contributor

@nikophil nikophil commented Jun 26, 2023

Q A
Branch? 6.4
Bug fix? no
New feature? yes
Deprecations? no
License MIT
Doc PR will be done if bugfix gets accepted

(this PR is a split of #50775)

this PR proposes to improve the listener's method resolution by:

  1. checking if a method with the "camelized" name exist.
  2. If it does not, we evaluate if one unique public method exists which would take the event as unique parameter (ie: the listener definition above would resolve someMethod() as the listener's method).
  3. if an __invoke method exist we'll use this one without checking its parameters (this is also useful for BC)
  4. Otherwise, method name needs to be provided and an exception is thrown

ping @GromNaN

(CI failures seems unrelated to this PR 🤔 )

@carsonbot carsonbot added this to the 6.4 milestone Jun 26, 2023
@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
@xabbuh xabbuh modified the milestones: 7.1, 7.2 May 15, 2024
Copy link
Member

@nicolas-grekas nicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Here are minor comments. Please rebase while addressing them.

@nikophil nikophil force-pushed the feat/resolve-listener-method branch from f2bcee9 to d2ebe37 Compare August 29, 2024 07:32
@nikophil nikophil force-pushed the feat/resolve-listener-method branch from d2ebe37 to dcefe70 Compare August 29, 2024 07:33
foreach ($publicMethods as $publicMethod) {
if (
!$publicMethod->isStatic()
&& 1 === $publicMethod->getNumberOfRequiredParameters()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check is bad given that the EventDispatcher component actually provides 3 parameters to listeners:

  • the event object
  • the event name
  • the EventDispatcher instance

@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
@chalasr
Copy link
Member

chalasr commented Mar 29, 2025

@nikophil any chance you handle the remaining comments?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.