From f4f57c9d8d7008aca990c30ba641c4ea8723cfb4 Mon Sep 17 00:00:00 2001 From: Chris Morrell Date: Wed, 24 Jan 2024 11:43:27 -0500 Subject: [PATCH] Refactor hook calls --- src/Hook.php | 4 ++-- src/Hooks.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Hook.php b/src/Hook.php index 3a45b2f..1443a6d 100644 --- a/src/Hook.php +++ b/src/Hook.php @@ -18,8 +18,8 @@ public function __construct( ) { } - public function __invoke(array $arguments, Context $context): Context + public function __invoke(array $arguments): mixed { - return $context->addResult(call_user_func_array($this->callback, [...$arguments, $context])); + return call_user_func_array($this->callback, $arguments); } } diff --git a/src/Hooks.php b/src/Hooks.php index 2462f87..b021e0d 100644 --- a/src/Hooks.php +++ b/src/Hooks.php @@ -52,7 +52,7 @@ public function run(string $name, array $arguments): Context $context = new Context($data); foreach ($this->getHooks($name) as $hook) { - $hook($arguments, $context); + $context->addResult($hook([...$arguments, $context])); if ($context->should_stop_propagation) { break;