Skip to content

Made the $event parameter of EventManager::getListeners() mandatory#57

Merged
derrabus merged 1 commit intodoctrine:2.0.xfrom
derrabus:improvement/mandatory-event-param
Oct 10, 2022
Merged

Made the $event parameter of EventManager::getListeners() mandatory#57
derrabus merged 1 commit intodoctrine:2.0.xfrom
derrabus:improvement/mandatory-event-param

Conversation

@derrabus
Copy link
Member

Follows #50.

@derrabus derrabus added this to the 2.0.0 milestone Oct 10, 2022
return $this->getAllListeners();
}

return $this->listeners[$event];
Copy link
Member

Choose a reason for hiding this comment

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

Now I'm seeing this method clearly it occurred to me :D What about an event that has no listeners? Is calling hasListeners the way to go? Right now this will emit PHP's warning about undefined key, which will hopefully be transformed into an exception. Maybe ?? [] should be used instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Returning an empty array sounds like the reasonable thing to do.

@derrabus derrabus merged commit 95c15e5 into doctrine:2.0.x Oct 10, 2022
@derrabus derrabus deleted the improvement/mandatory-event-param branch October 10, 2022 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants