diff options
| author | 2024-07-29 14:48:17 +0200 | |
|---|---|---|
| committer | 2024-07-29 14:48:17 +0200 | |
| commit | 5c8369ce38c67fba7dd39d68626534c7e61eb24c (patch) | |
| tree | 546f6ce7325ae557cb7e67b09224d49ce2caf1f1 /lib | |
| parent | 47a3e15edc2a2e9d76a3374a2f5ed7197b2aedea (diff) | |
Strong type array parameter helper (#6661)
Also useful for extensions (including one I am writing)
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/Minz/Request.php | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/Minz/Request.php b/lib/Minz/Request.php index 301bd5623..8121eb104 100644 --- a/lib/Minz/Request.php +++ b/lib/Minz/Request.php @@ -69,6 +69,15 @@ class Minz_Request { return $specialchars ? Minz_Helper::htmlspecialchars_utf8(self::$params[$key]) : self::$params[$key]; } + /** @return array<string> */ + public static function paramArrayString(string $key, bool $specialchars = false): array { + if (empty(self::$params[$key]) || !is_array(self::$params[$key])) { + return []; + } + $result = array_filter(self::$params[$key], 'is_string'); + return $specialchars ? Minz_Helper::htmlspecialchars_utf8($result) : $result; + } + public static function paramTernary(string $key): ?bool { if (isset(self::$params[$key])) { $p = self::$params[$key]; |
