From a80a5f48a16e7d232168a7aaa68e9a1804235ce1 Mon Sep 17 00:00:00 2001 From: Alexandre Alapetite Date: Mon, 18 Dec 2023 17:59:16 +0100 Subject: Pass PHPStan level 8 (#5946) * Pass PHPStan level 8 And prepare for PHPStan level 9 https://phpstan.org/user-guide/rule-levels * Revert wrong replace in comment * Fix PHPStan level 8 * Update PHPStan and other dev dependencies * Remove obsolete comment * noVariableVariables and towards bleedingEdge https://github.com/phpstan/phpstan-strict-rules https://phpstan.org/blog/what-is-bleeding-edge * More bleedingEdge * A bit more PHPStan level 9 * More PHPStan level 9 * Prepare for booleansInConditions Ignore int and null * Revert wrong line * More fixes * Fix keep_max_n_unread * Stricter attribute functions * Stricter callHooks and more PHPStan level 9 * More typing * A tiny more --- p/api/fever.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) (limited to 'p/api/fever.php') diff --git a/p/api/fever.php b/p/api/fever.php index cc5778e9f..8cf3dfc21 100644 --- a/p/api/fever.php +++ b/p/api/fever.php @@ -19,7 +19,7 @@ require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader FreshRSS_Context::initSystem(); // check if API is enabled globally -if (FreshRSS_Context::$system_conf == null || !FreshRSS_Context::$system_conf->api_enabled) { +if (!FreshRSS_Context::hasSystemConf() || !FreshRSS_Context::systemConf()->api_enabled) { Minz_Log::warning('Fever API: service unavailable!'); Minz_Log::debug('Fever API: serviceUnavailable() ' . debugInfo(), API_LOG); header('HTTP/1.1 503 Service Unavailable'); @@ -149,20 +149,17 @@ final class FeverAPI * your FreshRSS "username:your-api-password" combination */ private function authenticate(): bool { - if (FreshRSS_Context::$system_conf === null) { - throw new FreshRSS_Context_Exception('System configuration not initialised!'); - } - FreshRSS_Context::$user_conf = null; + FreshRSS_Context::clearUserConf(); Minz_User::change(); $feverKey = empty($_POST['api_key']) ? '' : substr(trim($_POST['api_key']), 0, 128); if (ctype_xdigit($feverKey)) { $feverKey = strtolower($feverKey); - $username = @file_get_contents(DATA_PATH . '/fever/.key-' . sha1(FreshRSS_Context::$system_conf->salt) . '-' . $feverKey . '.txt', false); + $username = @file_get_contents(DATA_PATH . '/fever/.key-' . sha1(FreshRSS_Context::systemConf()->salt) . '-' . $feverKey . '.txt', false); if ($username != false) { $username = trim($username); - FreshRSS_Context::$user_conf = FreshRSS_Context::initUser($username); // Assignment to help PHPStan - if (FreshRSS_Context::$user_conf != null && $feverKey === FreshRSS_Context::$user_conf->feverKey && FreshRSS_Context::$user_conf->enabled) { - Minz_Translate::init(FreshRSS_Context::$user_conf->language); + FreshRSS_Context::initUser($username); + if ($feverKey === FreshRSS_Context::userConf()->feverKey && FreshRSS_Context::userConf()->enabled) { + Minz_Translate::init(FreshRSS_Context::userConf()->language); $this->entryDAO = FreshRSS_Factory::createEntryDao(); $this->feedDAO = FreshRSS_Factory::createFeedDao(); return true; @@ -180,7 +177,7 @@ final class FeverAPI public function isAuthenticatedApiUser(): bool { $this->authenticate(); - return FreshRSS_Context::$user_conf !== null; + return FreshRSS_Context::hasUserConf(); } /** @@ -350,11 +347,11 @@ final class FeverAPI /** @return array> */ private function getFavicons(): array { - if (FreshRSS_Context::$system_conf == null) { + if (!FreshRSS_Context::hasSystemConf()) { return []; } $favicons = array(); - $salt = FreshRSS_Context::$system_conf->salt; + $salt = FreshRSS_Context::systemConf()->salt; $myFeeds = $this->feedDAO->listFeeds(); foreach ($myFeeds as $feed) { -- cgit v1.2.3