aboutsummaryrefslogtreecommitdiff
path: root/lib/Minz/Request.php
diff options
context:
space:
mode:
authorGravatar Alexandre Alapetite <alexandre@alapetite.fr> 2023-04-04 10:23:26 +0200
committerGravatar GitHub <noreply@github.com> 2023-04-04 10:23:26 +0200
commit36aa0122e15b6c5a4bf923467b63a577cac5a539 (patch)
tree3dc7d2c5143157165f0248fab7470f86f76b0898 /lib/Minz/Request.php
parent2340f7a1bac38647f0267c1d7143c0cf04d68fcc (diff)
Fix extensions in actualize_script (#5243)
* Fix extension freshrss_user_maintenance in actualize_script Follow-up of https://github.com/FreshRSS/FreshRSS/pull/3440 The hook was called before registering all the extensions for the current user * PHPStan Level 6 for extensions And remove 5-year old legacy format of enabled extensions < FreshRSS 1.11.1 * Fix multiple bugs in extensions * Minor typing * Don't change signature of methods supposed to be overridden * PHPStan Level 9 and compatibility Intelliphense * Set as final the methods not supposed to be overriden
Diffstat (limited to 'lib/Minz/Request.php')
-rw-r--r--lib/Minz/Request.php28
1 files changed, 22 insertions, 6 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php
index bcd914612..a296f3b39 100644
--- a/lib/Minz/Request.php
+++ b/lib/Minz/Request.php
@@ -36,7 +36,7 @@ class Minz_Request {
* @param bool $specialchars special characters
* @return mixed value of the parameter
*/
- public static function param($key, $default = false, $specialchars = false) {
+ public static function param(string $key, $default = false, bool $specialchars = false) {
if (isset(self::$params[$key])) {
$p = self::$params[$key];
if (is_object($p) || $specialchars) {
@@ -48,12 +48,13 @@ class Minz_Request {
return $default;
}
}
- public static function paramTernary($key) {
+
+ /** @return bool|null */
+ public static function paramTernary(string $key) {
if (isset(self::$params[$key])) {
$p = self::$params[$key];
- $tp = trim($p);
- // @phpstan-ignore-next-line
- if ($p === null || $tp === '' || $tp === 'null') {
+ $tp = is_string($p) ? trim($p) : true;
+ if ($tp === '' || $tp === 'null') {
return null;
} elseif ($p == false || $tp == '0' || $tp === 'false' || $tp === 'no') {
return false;
@@ -62,12 +63,27 @@ class Minz_Request {
}
return null;
}
- public static function paramBoolean($key) {
+
+ public static function paramBoolean(string $key): bool {
if (null === $value = self::paramTernary($key)) {
return false;
}
return $value;
}
+
+ public static function paramString(string $key): string {
+ if (isset(self::$params[$key])) {
+ $s = self::$params[$key];
+ if (is_string($s)) {
+ return trim($s);
+ }
+ if (is_int($s) || is_bool($s)) {
+ return (string)$s;
+ }
+ }
+ return '';
+ }
+
/**
* Extract text lines to array.
*