diff options
author | Andrew Dolgov <[email protected]> | 2021-11-14 11:11:49 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-11-14 11:11:49 +0300 |
commit | 0a2dcacbcf01e1ebb225570fb99811c4215c6ea9 (patch) | |
tree | 8ffae105e37718ecbd8a0de723ee95b68fb893c7 /classes | |
parent | 81a10f69bcc38b62aad79f9be716adcf4ed49d2d (diff) |
normalize some mismatching hook function definitions to match base Plugin class
Diffstat (limited to 'classes')
-rw-r--r-- | classes/auth/base.php | 4 | ||||
-rw-r--r-- | classes/iauthmodule.php | 10 | ||||
-rw-r--r-- | classes/plugin.php | 27 |
3 files changed, 29 insertions, 12 deletions
diff --git a/classes/auth/base.php b/classes/auth/base.php index 939a9d358..9950cbf07 100644 --- a/classes/auth/base.php +++ b/classes/auth/base.php @@ -8,8 +8,8 @@ abstract class Auth_Base extends Plugin implements IAuthModule { $this->pdo = Db::pdo(); } - function hook_auth_user(...$args) { - return $this->authenticate(...$args); + function hook_auth_user($login, $password, $service = '') { + return $this->authenticate($login, $password, $service); } // Auto-creates specified user if allowed by system configuration diff --git a/classes/iauthmodule.php b/classes/iauthmodule.php index 39aae4cc2..dbf8c5587 100644 --- a/classes/iauthmodule.php +++ b/classes/iauthmodule.php @@ -3,14 +3,16 @@ interface IAuthModule { /** * @param string $login * @param string $password - * optional third string $service + * @param string $service * @return int|false user_id */ - function authenticate($login, $password); // + optional third parameter: $service + function authenticate($login, $password, $service = ''); /** this is a pluginhost compatibility wrapper that invokes $this->authenticate(...$args) (Auth_Base) - * @param mixed $args = ($login, $password, $service) + * @param string $login + * @param string $password + * @param string $service * @return int|false user_id */ - function hook_auth_user(...$args); + function hook_auth_user($login, $password, $service = ''); } diff --git a/classes/plugin.php b/classes/plugin.php index bcd8c0de7..8c14cd78d 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -1,4 +1,11 @@ <?php +/* TODO: I haven't yet decided if we're keeping hook prototypes which did grow (with additional params) over time and breaking all plugins + with legacy function definitions, or commenting base definitions out for the time being -fox + + (It's a shame that PHP doesn't support argument overloading) + + Stuff like hook_enclosure_entry() etc. +*/ abstract class Plugin { const API_VERSION_COMPAT = 1; @@ -142,10 +149,12 @@ abstract class Plugin { } /** this is a pluginhost compatibility wrapper that invokes $this->authenticate(...$args) (Auth_Base) - * @param mixed $args = ($login, $password, $service) + * @param string $login + * @param string $password + * @param string $service * @return int|false user_id */ - function hook_auth_user(...$args) { + function hook_auth_user($login, $password, $service = '') { user_error("Dummy method invoked.", E_USER_ERROR); return false; } @@ -153,10 +162,10 @@ abstract class Plugin { /** IAuthModule only * @param string $login * @param string $password - * optional third string $service + * @param string $service * @return int|false user_id */ - function authenticate($login, $password) { + function authenticate($login, $password, $service = '') { user_error("Dummy method invoked.", E_USER_ERROR); return false; } @@ -257,6 +266,12 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } + /** + * @param array<string,string> $entry + * @param int $id + * @param array{'formatted': string, 'entries': array<int, array<string, mixed>>} $rv + * @return array<string,string> + */ function hook_enclosure_entry($entry, $id, $rv) { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -289,7 +304,7 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } - function hook_article_image($enclosures, $content, $site_url) { + function hook_article_image($enclosures, $content, $site_url, $article) { user_error("Dummy method invoked.", E_USER_ERROR); } @@ -317,7 +332,7 @@ abstract class Plugin { user_error("Dummy method invoked.", E_USER_ERROR); } - function hook_pre_subscribe($url, $auth_login, $auth_pass) { + function hook_pre_subscribe(&$url, $auth_login, $auth_pass) { user_error("Dummy method invoked.", E_USER_ERROR); } } |