From 2b45b52477bd593a1eb94e97223a6f830b45fae4 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 6 Feb 2017 10:38:01 +0100 Subject: [PATCH] fix warning about static use of Accounts::is_(active|expried) by making it static and throw a WrongParameterException, if is_expired is called with no parameter --- api/src/Accounts.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/api/src/Accounts.php b/api/src/Accounts.php index c051046825..2a3f3ed3f7 100644 --- a/api/src/Accounts.php +++ b/api/src/Accounts.php @@ -688,16 +688,18 @@ class Accounts } /** - * test if an account is expired + * Test if given an account is expired * - * Can be used static if array with user-data is supplied - * - * @param array $data =null array with account data, not specifying the account is depricated!!! + * @param int|string|array $data account_(l)id or array with account-data * @return boolean true=expired (no more login possible), false otherwise */ - function is_expired($data=null) + static function is_expired($data) { - if (is_null($data)) $data = $this->data; // depricated use + if (is_null($data)) + { + throw new Exception\WrongParameter('Missing parameter to Accounts::is_active()'); + } + if (!is_array($data)) $data = self::getInstance()->read($data); $expires = isset($data['account_expires']) ? $data['account_expires'] : $data['expires']; @@ -707,14 +709,12 @@ class Accounts /** * Test if an account is active - NOT deactivated or expired * - * Can be used static if array with user-data is supplied - * - * @param int|array $data account_id or array with account-data + * @param int|string|array $data account_(l)id or array with account-data * @return boolean false if account does not exist, is expired or decativated, true otherwise */ - function is_active($data) + static function is_active($data) { - if (!is_array($data)) $data = $this->read($data); + if (!is_array($data)) $data = self::getInstance()->read($data); return $data && !(self::is_expired($data) || $data['account_status'] != 'A'); }