Pass an arbitrary number of arguments to event listener. #15
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes issue #14
The existing problems, as I understand them, are:
emit
function as defined inBaun\Interfaces\Events
expects the second parameter to be an array of arguments, however, when theemit
function is called from within the Baun application, this is never the case.emit
function is called from the Baun application, but due to theEvents
provider only handling one argument, anything after the first argument is simply ignored.emit
method inBaun\Providers\Events
sends the arguments in an array toLeague\Event\Emitter
'semit
function, which is incorrect; it doesn't expect an array of parameters, it expects any arbitrary number of parameters which it accesses viauser_func_get_args()
So, I have modified
Baun\Interfaces\Events
to not take an$args
parameter. Instead, it can take an arbitrary number of additional arguments which it will callLeague\Event\Emitter::emit
usingcall_user_func_array()
with an array of arguments fromfunc_get_args()
.Hopefully this now makes the Baun framework consistent with
Leage\Event
and behave in the way that most people will expect it to. :)