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/Models/UserConfiguration.php | 42 +++++++++++++++++++++++++++------------- 1 file changed, 29 insertions(+), 13 deletions(-) (limited to 'app/Models/UserConfiguration.php') diff --git a/app/Models/UserConfiguration.php b/app/Models/UserConfiguration.php index 0aec3a05f..a1e0dbbaa 100644 --- a/app/Models/UserConfiguration.php +++ b/app/Models/UserConfiguration.php @@ -70,6 +70,7 @@ declare(strict_types=1); * @property-read bool $unsafe_autologin_enabled * @property string $view_mode * @property array $volatile + * @property array> $extensions */ final class FreshRSS_UserConfiguration extends Minz_Configuration { use FreshRSS_FilterActionsTrait; @@ -81,22 +82,37 @@ final class FreshRSS_UserConfiguration extends Minz_Configuration { } /** - * @phpstan-return ($key is non-empty-string ? mixed : array) - * @return array|mixed|null + * @param non-empty-string $key + * @return array|null */ - public function attributes(string $key = '') { - if ($key === '') { - return []; // Not implemented for user configuration - } else { - return parent::param($key, null); - } + public function attributeArray(string $key): ?array { + $a = parent::param($key, null); + return is_array($a) ? $a : null; } - /** @param string|array|bool|int|null $value Value, not HTML-encoded */ - public function _attributes(string $key, $value = null): void { - if ($key == '') { - return; // Not implemented for user configuration - } + /** @param non-empty-string $key */ + public function attributeBool(string $key): ?bool { + $a = parent::param($key, null); + return is_bool($a) ? $a : null; + } + + /** @param non-empty-string $key */ + public function attributeInt(string $key): ?int { + $a = parent::param($key, null); + return is_numeric($a) ? (int)$a : null; + } + + /** @param non-empty-string $key */ + public function attributeString(string $key): ?string { + $a = parent::param($key, null); + return is_string($a) ? $a : null; + } + + /** + * @param non-empty-string $key + * @param array|mixed|null $value Value, not HTML-encoded + */ + public function _attribute(string $key, $value = null): void { parent::_param($key, $value); } } -- cgit v1.2.3