Simplify callback arguments? #5

Open
opened 2019-12-31 13:12:31 -08:00 by pwFoo · 0 comments
pwFoo commented 2019-12-31 13:12:31 -08:00 (Migrated from github.com)

I don't know if it would be easy to do, but would be great if we don't need to write all the default arguments to a hook?

Would it possible to move the arguments to the class instead to repeat in the users code?

[...] function(&$arguments, $name, &$object, &$function, &$data)

I don't know if possible in that context. but maybe it's possible to inject the original method arguments / data by "use" behind the function () use [...] in Hook.php or build a single object like $event with all the data?

$event->object // original object
$event->arguments() // all arguments
$event->arguments(0) // first argument
$event->arguments('name') // argument by name
[...]
I don't know if it would be easy to do, but would be great if we don't need to write all the default arguments to a hook? Would it possible to move the arguments to the class instead to repeat in the users code? ``` [...] function(&$arguments, $name, &$object, &$function, &$data) ``` I don't know if possible in that context. but maybe it's possible to inject the original method arguments / data by "use" behind the `function () use [...]` in Hook.php or build a single object like `$event` with all the data? ``` $event->object // original object $event->arguments() // all arguments $event->arguments(0) // first argument $event->arguments('name') // argument by name [...] ```
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sciactive/hookphp#5
No description provided.