aboutsummaryrefslogtreecommitdiff
path: root/app/Models/UserConfiguration.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-12-18 17:59:16 +0100
committerGravatar GitHub <noreply@github.com> 2023-12-18 17:59:16 +0100
commita80a5f48a16e7d232168a7aaa68e9a1804235ce1 (patch)
treea515b88592629dea7e83b96e26e2452d3f98a98e /app/Models/UserConfiguration.php
parent6bb45a87268157aab961a6a4a728d9a9bbe043b0 (diff)
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
Diffstat (limited to 'app/Models/UserConfiguration.php')
-rw-r--r--app/Models/UserConfiguration.php42
1 files changed, 29 insertions, 13 deletions
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<string,mixed> $volatile
+ * @property array<string,array<string,mixed>> $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<string,mixed>)
- * @return array<string,mixed>|mixed|null
+ * @param non-empty-string $key
+ * @return array<int|string,mixed>|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<mixed>|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<string,mixed>|mixed|null $value Value, not HTML-encoded
+ */
+ public function _attribute(string $key, $value = null): void {
parent::_param($key, $value);
}
}