From 413446611957fe022805a323a1261ed8d7738e8b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Mon, 20 Apr 2020 17:12:08 -0700 Subject: [PATCH] (REF) CRM_Utils_Hook - Remove deprecated formulations of `invoke(int,...)` Overview -------- The signature of `CRM_Utils_Hook::invoke()` originally took an argument `int $count` (number of hook args), but circa 4.7 it changed to prefer `string[] $names` (symbolic names for each hook arg). The `int` notation doesn't provide enough information to fire via Symfony EventDispatcher and was mostly replaced/deprecated, but `int` notation is still supported for backward compatibility. This cleans a couple oddballs using the `int` notation. Before ------ Some stub functions in `CRM_Utils_Hook` still use the `invoke(int,...)` formulation: * `hook_themes` fell through a crack because it had a long PR (years?) that overlapped with the change in `invoke()`. * `hook_install` (etc) looks like `int`, but it's not actually used. After ----- None of the stub functions in `CRM_Utils_Hook::invoke(string[], ...)` use `int` formulation. --- CRM/Utils/Hook.php | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/CRM/Utils/Hook.php b/CRM/Utils/Hook.php index d634c0c7a1..2b0fd9a379 100644 --- a/CRM/Utils/Hook.php +++ b/CRM/Utils/Hook.php @@ -662,7 +662,7 @@ abstract class CRM_Utils_Hook { * the return value is ignored */ public static function themes(&$themes) { - return self::singleton()->invoke(1, $themes, + return self::singleton()->invoke(['themes'], $themes, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, self::$_nullObject, 'civicrm_themes' ); @@ -1745,11 +1745,8 @@ abstract class CRM_Utils_Hook { * installation of unrelated modules). */ public static function install() { - return self::singleton()->invoke(0, self::$_nullObject, - self::$_nullObject, self::$_nullObject, - self::$_nullObject, self::$_nullObject, self::$_nullObject, - 'civicrm_install' - ); + // Actually invoke via CRM_Extension_Manager_Module::callHook + throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); } /** @@ -1758,11 +1755,8 @@ abstract class CRM_Utils_Hook { * uninstallation of unrelated modules). */ public static function uninstall() { - return self::singleton()->invoke(0, self::$_nullObject, - self::$_nullObject, self::$_nullObject, - self::$_nullObject, self::$_nullObject, self::$_nullObject, - 'civicrm_uninstall' - ); + // Actually invoke via CRM_Extension_Manager_Module::callHook + throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); } /** @@ -1771,11 +1765,8 @@ abstract class CRM_Utils_Hook { * re-enablement of unrelated modules). */ public static function enable() { - return self::singleton()->invoke(0, self::$_nullObject, - self::$_nullObject, self::$_nullObject, - self::$_nullObject, self::$_nullObject, self::$_nullObject, - 'civicrm_enable' - ); + // Actually invoke via CRM_Extension_Manager_Module::callHook + throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); } /** @@ -1784,11 +1775,8 @@ abstract class CRM_Utils_Hook { * disablement of unrelated modules). */ public static function disable() { - return self::singleton()->invoke(0, self::$_nullObject, - self::$_nullObject, self::$_nullObject, - self::$_nullObject, self::$_nullObject, self::$_nullObject, - 'civicrm_disable' - ); + // Actually invoke via CRM_Extension_Manager_Module::callHook + throw new \RuntimeException(sprintf("The method %s::%s is just a documentation stub and should not be invoked directly.", __CLASS__, __FUNCTION__)); } /** -- 2.25.1