From 65bc654315177d9a1fade48ba2bb190203e8c316 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 31 May 2021 00:27:04 -0700 Subject: [PATCH] HookStyleListener - Convey hook results. Refine type-hints. Note: This is uncommon and discouraged for new hooks, but some hooks require returning values, e.g ```php function hook_foo() { return ['my-data']; } ``` This should fix compatibility with those. --- Civi/Core/Event/HookStyleListener.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Civi/Core/Event/HookStyleListener.php b/Civi/Core/Event/HookStyleListener.php index e901f30c86..28a3ee85a8 100644 --- a/Civi/Core/Event/HookStyleListener.php +++ b/Civi/Core/Event/HookStyleListener.php @@ -30,10 +30,11 @@ class HookStyleListener { } public function __invoke(GenericHookEvent $e) { - return call_user_func_array($this->callback, $e->getHookValues()); + $result = call_user_func_array($this->callback, $e->getHookValues()); + $e->addReturnValues($result); } - public function __toString() { + public function __toString(): string { $name = EventPrinter::formatName($this->callback); return preg_replace('/\(\$?e?\)$/', '(&...)', $name); } -- 2.25.1