Skip to content
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

Improve static analysis on AttachEntityListenersListener #11272

Merged
merged 1 commit into from Feb 20, 2024

Conversation

greg0ire
Copy link
Member

Improve static analysis on AttachEntityListenersListener

$listenerCallback is supposed to be a method name, so it is safe to
require it is not a falsy string.

$listenerCallback is supposed to be a method name, so it is safe to
require it is not a falsy string.
@greg0ire greg0ire marked this pull request as ready for review February 19, 2024 08:43
* @param class-string $entityClass The entity to attach the listener.
* @param class-string $listenerClass The listener class.
* @param Events::*|null $eventName The entity lifecycle event.
* @param non-falsy-string|null $listenerCallback The listener callback method or NULL to use $eventName.
*/
public function addEntityListener(
Copy link
Member Author

@greg0ire greg0ire Feb 19, 2024

Choose a reason for hiding this comment

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

Note: it's unclear to me who/what calls this method. The class is not referenced at all in src, but it is referenced in the Symfony bundle. I suspect the method might only be there for test purposes. That class was introduced in #850

Copy link
Member

Choose a reason for hiding this comment

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

Possible. I remember when entitylisteners could only be configured with annotations in the entity class itself and there was no way to inject dependencies into the listener's constructor.

* @param class-string $entityClass The entity to attach the listener.
* @param class-string $listenerClass The listener class.
* @param Events::*|null $eventName The entity lifecycle event.
* @param non-falsy-string|null $listenerCallback The listener callback method or NULL to use $eventName.
*/
public function addEntityListener(
Copy link
Member

Choose a reason for hiding this comment

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

Possible. I remember when entitylisteners could only be configured with annotations in the entity class itself and there was no way to inject dependencies into the listener's constructor.

@greg0ire greg0ire added this to the 3.1.0 milestone Feb 20, 2024
@greg0ire greg0ire merged commit b1f553e into doctrine:3.1.x Feb 20, 2024
64 checks passed
@greg0ire greg0ire deleted the sa-attach-entity-listener branch February 20, 2024 07:14
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.

None yet

2 participants