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 --- app/install.php | 43 ++++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'app/install.php') diff --git a/app/install.php b/app/install.php index 348ba079b..b4da2911f 100644 --- a/app/install.php +++ b/app/install.php @@ -70,20 +70,20 @@ function saveStep1(): void { // First, we try to get previous configurations FreshRSS_Context::initSystem(); - FreshRSS_Context::initUser(FreshRSS_Context::$system_conf->default_user, false); + FreshRSS_Context::initUser(FreshRSS_Context::systemConf()->default_user, false); // Then, we set $_SESSION vars Minz_Session::_params([ - 'title' => FreshRSS_Context::$system_conf->title, - 'auth_type' => FreshRSS_Context::$system_conf->auth_type, - 'default_user' => Minz_User::name(), - 'passwordHash' => FreshRSS_Context::$user_conf->passwordHash, - 'bd_type' => FreshRSS_Context::$system_conf->db['type'] ?? '', - 'bd_host' => FreshRSS_Context::$system_conf->db['host'] ?? '', - 'bd_user' => FreshRSS_Context::$system_conf->db['user'] ?? '', - 'bd_password' => FreshRSS_Context::$system_conf->db['password'] ?? '', - 'bd_base' => FreshRSS_Context::$system_conf->db['base'] ?? '', - 'bd_prefix' => FreshRSS_Context::$system_conf->db['prefix'] ?? '', + 'title' => FreshRSS_Context::systemConf()->title, + 'auth_type' => FreshRSS_Context::systemConf()->auth_type, + 'default_user' => Minz_User::name() ?? '', + 'passwordHash' => FreshRSS_Context::userConf()->passwordHash, + 'bd_type' => FreshRSS_Context::systemConf()->db['type'] ?? '', + 'bd_host' => FreshRSS_Context::systemConf()->db['host'] ?? '', + 'bd_user' => FreshRSS_Context::systemConf()->db['user'] ?? '', + 'bd_password' => FreshRSS_Context::systemConf()->db['password'] ?? '', + 'bd_base' => FreshRSS_Context::systemConf()->db['base'] ?? '', + 'bd_prefix' => FreshRSS_Context::systemConf()->db['prefix'] ?? '', 'bd_error' => false, ]); @@ -191,33 +191,34 @@ function saveStep3(): bool { Minz_Translate::init(Minz_Session::paramString('language')); if (!empty($_POST)) { - if (param('auth_type', 'form') != '') { - FreshRSS_Context::$system_conf->auth_type = param('auth_type', 'form'); - Minz_Session::_param('auth_type', FreshRSS_Context::$system_conf->auth_type); + $auth_type = param('auth_type', 'form'); + if (in_array($auth_type, ['form', 'http_auth', 'none'], true)) { + FreshRSS_Context::systemConf()->auth_type = $auth_type; + Minz_Session::_param('auth_type', FreshRSS_Context::systemConf()->auth_type); } else { return false; } $password_plain = param('passwordPlain', ''); - if (FreshRSS_Context::$system_conf->auth_type === 'form' && $password_plain == '') { + if (FreshRSS_Context::systemConf()->auth_type === 'form' && $password_plain == '') { return false; } if (FreshRSS_user_Controller::checkUsername(param('default_user', ''))) { - FreshRSS_Context::$system_conf->default_user = param('default_user', ''); - Minz_Session::_param('default_user', FreshRSS_Context::$system_conf->default_user); + FreshRSS_Context::systemConf()->default_user = param('default_user', ''); + Minz_Session::_param('default_user', FreshRSS_Context::systemConf()->default_user); } else { return false; } - if (FreshRSS_Context::$system_conf->auth_type === 'http_auth' && + if (FreshRSS_Context::systemConf()->auth_type === 'http_auth' && connectionRemoteAddress() !== '' && empty($_SERVER['REMOTE_USER']) && empty($_SERVER['REDIRECT_REMOTE_USER']) && // No safe authentication HTTP headers (!empty($_SERVER['HTTP_REMOTE_USER']) || !empty($_SERVER['HTTP_X_WEBAUTH_USER'])) // but has unsafe authentication HTTP headers ) { // Trust by default the remote IP address (e.g. last proxy) used during install to provide remote user name via unsafe HTTP header - FreshRSS_Context::$system_conf->trusted_sources[] = connectionRemoteAddress(); - FreshRSS_Context::$system_conf->trusted_sources = array_unique(FreshRSS_Context::$system_conf->trusted_sources); + FreshRSS_Context::systemConf()->trusted_sources[] = connectionRemoteAddress(); + FreshRSS_Context::systemConf()->trusted_sources = array_unique(FreshRSS_Context::systemConf()->trusted_sources); } // Create default user files but first, we delete previous data to @@ -244,7 +245,7 @@ function saveStep3(): bool { return false; } - FreshRSS_Context::$system_conf->save(); + FreshRSS_Context::systemConf()->save(); header('Location: index.php?step=4'); } -- cgit v1.2.3