diff options
| author | 2023-04-14 14:23:45 +0200 | |
|---|---|---|
| committer | 2023-04-14 14:23:45 +0200 | |
| commit | b3121709d62d9fadf890e523b9c9dba7cf702d25 (patch) | |
| tree | 17da25c780ca11a76e0e456584790937cb993203 /lib | |
| parent | 61550b1d2d995896a6bf2ee854e19b6210026674 (diff) | |
PHPStan Level 6 FreshRSS_Search FreshRSS_Entry (#5292)
* PHPStan Level 6 FreshRSS_Search FreshRSS_Entry
* Minor fix
* Type fix
* Apply suggestions from code review
Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
* Minor types syntax
Compatibility Intelephense
---------
Co-authored-by: Luc SANCHEZ <4697568+ColonelMoutarde@users.noreply.github.com>
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Minz/Helper.php | 7 | ||||
| -rw-r--r-- | lib/Minz/Request.php | 9 |
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/Minz/Helper.php b/lib/Minz/Helper.php index 92e97ad6c..8ecc1af8d 100644 --- a/lib/Minz/Helper.php +++ b/lib/Minz/Helper.php @@ -12,8 +12,13 @@ class Minz_Helper { /** * Wrapper for htmlspecialchars. * Force UTf-8 value and can be used on array too. + * + * @phpstan-template T of string|array<mixed> + * @phpstan-param T $var + * @phpstan-return T + * * @param string|array<string> $var - * @return ($var is array ? array<string> : string) + * @return string|array<string> */ public static function htmlspecialchars_utf8($var) { if (is_array($var)) { diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index a03aff18b..7957610e2 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -49,8 +49,10 @@ class Minz_Request { $p = self::$params[$key]; if (is_object($p) || $specialchars) { return $p; - } else { + } elseif (is_string($p) || is_array($p)) { return Minz_Helper::htmlspecialchars_utf8($p); + } else { + return $p; } } else { return $default; @@ -66,8 +68,7 @@ class Minz_Request { return $specialchars ? Minz_Helper::htmlspecialchars_utf8(self::$params[$key]) : self::$params[$key]; } - /** @return bool|null */ - public static function paramTernary(string $key) { + public static function paramTernary(string $key): ?bool { if (isset(self::$params[$key])) { $p = self::$params[$key]; $tp = is_string($p) ? trim($p) : true; @@ -457,7 +458,7 @@ class Minz_Request { /** * @return array<string> */ - public static function getPreferredLanguages() { + public static function getPreferredLanguages(): array { if (preg_match_all('/(^|,)\s*(?P<lang>[^;,]+)/', $_SERVER['HTTP_ACCEPT_LANGUAGE'] ?? '', $matches)) { return $matches['lang']; } |
