DDC-424: Remove EventArgs::getEmptyInstance() #528

Closed
opened 2026-01-22 12:41:32 +01:00 by admin · 5 comments
Owner

Originally created by @doctrinebot on GitHub (Mar 14, 2010).

Jira issue originally created by user shurakai:

I can't see what this method is good for? It is only used in the EventManager (line 61) and I think using "new EventArgs()" instead would be equivalent?

Thanks for clarification.

Originally created by @doctrinebot on GitHub (Mar 14, 2010). Jira issue originally created by user shurakai: I can't see what this method is good for? It is only used in the EventManager (line 61) and I think using "new EventArgs()" instead would be equivalent? Thanks for clarification.
admin added the Improvement label 2026-01-22 12:41:32 +01:00
admin closed this issue 2026-01-22 12:41:33 +01:00
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2010):

Comment created by romanb:

Every event that does not need a special EventArgs instance because it doesnt carry any additional event information can use this instance, which is much more efficient than creating a new instance every time. Any event can be dispatched via: $evm->dispatchEvent(Events::foo); and this will automatically re-use the immutable, empty instance.

To answer your question, yes using "new EventArgs()" would be quivalent but would use X objects (where X can quickly become very large) instead of 1. Since the empty instance is immutable it is safe to share it.

@doctrinebot commented on GitHub (Mar 15, 2010): Comment created by romanb: Every event that does not need a special EventArgs instance because it doesnt carry any additional event information can use this instance, which is much more efficient than creating a new instance every time. Any event can be dispatched via: $evm->dispatchEvent(Events::foo); and this will automatically re-use the immutable, empty instance. To answer your question, yes using "new EventArgs()" would be quivalent but would use X objects (where X can quickly become very large) instead of 1. Since the empty instance is immutable it is safe to share it.
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2010):

Issue was closed with resolution "Invalid"

@doctrinebot commented on GitHub (Mar 15, 2010): Issue was closed with resolution "Invalid"
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2010):

Comment created by romanb:

(The concept is from .NET btw :) http://msdn.microsoft.com/en-us/library/system.eventargs.empty.aspx )

@doctrinebot commented on GitHub (Mar 15, 2010): Comment created by romanb: (The concept is from .NET btw :) http://msdn.microsoft.com/en-us/library/system.eventargs.empty.aspx )
Author
Owner

@doctrinebot commented on GitHub (Mar 15, 2010):

Comment created by shurakai:

Thanks for clarifying! I've added some documentation stating this exact purpose, maybe someone will find it helpful.

@doctrinebot commented on GitHub (Mar 15, 2010): Comment created by shurakai: Thanks for clarifying! I've added some documentation stating this exact purpose, maybe someone will find it helpful.
Author
Owner

@doctrinebot commented on GitHub (Dec 13, 2015):

Imported 1 attachments from Jira into https://gist.github.com/58632c7c43c07b080ac8

@doctrinebot commented on GitHub (Dec 13, 2015): Imported 1 attachments from Jira into https://gist.github.com/58632c7c43c07b080ac8 - [10477_eventargs_doc.patch](https://gist.github.com/58632c7c43c07b080ac8#file-10477_eventargs_doc-patch)
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#528