The Needs Review Queue Bot β tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".
Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.
Consult the Drupal Contributor Guide β to find step-by-step guides for working with issues.
- Status changed to Needs work
over 1 year ago 11:20pm 12 June 2023 - π«π·France andypost
There's performance measures of calls to hooks, for me the winner is fast-callable syntax after replacing fast-call with
$ff(...$args)
as patch in #3259716-67: Replace usages of static::class . '::methodName' to first-class callable syntax static::method(...) βhttps://gist.github.com/donquixote/85efcca90056111e967dd14cb1f9de9c
--- a/core/lib/Drupal/Core/Extension/ModuleHandler.php +++ b/core/lib/Drupal/Core/Extension/ModuleHandler.php @@ -384,7 +384,7 @@ public function hasImplementations(string $hook, $modules = NULL): bool { */ public function invokeAllWith(string $hook, callable $callback): void { foreach (array_keys($this->getImplementationInfo($hook)) as $module) { - $hookInvoker = \Closure::fromCallable($module . '_' . $hook); + $hookInvoker = ($module . '_' . $hook)(...); $callback($hookInvoker, $module); } } @@ -396,8 +396,8 @@ public function invoke($module, $hook, array $args = []) { if (!$this->hasImplementations($hook, $module)) { return; } - $hookInvoker = \Closure::fromCallable($module . '_' . $hook); - return call_user_func_array($hookInvoker, $args); + $hookInvoker = ($module . '_' . $hook)(...); + return $hookInvoker(...$args); }
- First commit to issue fork.
- Status changed to Needs review
10 months ago 3:31pm 11 February 2024 - Merge request !6544Issue #329012: Remove call_user_func_array() from ModuleHandler::invoke() + invokeAll() β (Open) created by casey
- Status changed to Needs work
10 months ago 2:37pm 14 February 2024 - πΊπΈUnited States smustgrave
Found 1 more code example but 3 in comments that maybe should be addressed too?