From 40aa8b9264f1918cb48a0e2f6fc00455181a004a Mon Sep 17 00:00:00 2001 From: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com> Date: Fri, 3 Feb 2023 14:35:59 +0100 Subject: Type hinting and doc (#5063) * Type hinting and doc * fix cs * Remove declare strict * Remove declare strict * Pass PHPStan level 9 Revert too boolean syntax * Minor wording * Fix revert typo --------- Co-authored-by: Luc Co-authored-by: Alexandre Alapetite --- app/Utils/feverUtil.php | 36 +++++++++++++++--------------------- 1 file changed, 15 insertions(+), 21 deletions(-) (limited to 'app/Utils/feverUtil.php') diff --git a/app/Utils/feverUtil.php b/app/Utils/feverUtil.php index 277230ec2..0e4b712ce 100644 --- a/app/Utils/feverUtil.php +++ b/app/Utils/feverUtil.php @@ -1,14 +1,14 @@ salt); return self::FEVER_PATH . '/.key-' . $salt . '-' . $feverKey . '.txt'; } /** * Update the fever key of a user. - * - * @param string $username - * @param string $passwordPlain * @return string|false the Fever key, or false if the update failed */ - public static function updateKey($username, $passwordPlain) { - $ok = self::checkFeverPath(); - if (!$ok) { + public static function updateKey(string $username, string $passwordPlain) { + if (!self::checkFeverPath()) { return false; } @@ -48,22 +44,20 @@ class FreshRSS_fever_Util { $feverKey = strtolower(md5("{$username}:{$passwordPlain}")); $feverKeyPath = self::getKeyPath($feverKey); - $res = file_put_contents($feverKeyPath, $username); - if ($res !== false) { + $result = file_put_contents($feverKeyPath, $username); + if (is_int($result) && $result > 0) { return $feverKey; - } else { - Minz_Log::warning('Could not save Fever API credentials. Unknown error.', ADMIN_LOG); - return false; } + Minz_Log::warning('Could not save Fever API credentials. Unknown error.', ADMIN_LOG); + return false; } /** * Delete the Fever key of a user. * - * @param string $username - * @return boolean true if the deletion succeeded, else false. + * @return bool true if the deletion succeeded, else false. */ - public static function deleteKey($username) { + public static function deleteKey(string $username) { $userConfig = get_user_configuration($username); if ($userConfig === null) { return false; -- cgit v1.2.3