diff options
| author | 2023-04-07 00:13:49 +0200 | |
|---|---|---|
| committer | 2023-04-07 00:13:49 +0200 | |
| commit | 6c01e4e7d6c177ac345c826059e585bffdd1d517 (patch) | |
| tree | 45bd8ee233a306881ed81447a3f56ca224fed538 /lib/Minz/Url.php | |
| parent | 2118448133e327294ad2b69ed8736bc29879103d (diff) | |
Use typed access to request parameters (#5267)
* Use typed access to request parameters
This was a big source of mixed datatypes in many places
* Fix notifications
* Fix bookmarkAction
Diffstat (limited to 'lib/Minz/Url.php')
| -rw-r--r-- | lib/Minz/Url.php | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index efffb7f25..80745848a 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -19,7 +19,7 @@ class Minz_Url { $isArray = is_array($url); if ($isArray) { - $url = self::checkUrl($url); + $url = self::checkControllerUrl($url); } $url_string = ''; @@ -107,23 +107,21 @@ class Minz_Url { } /** - * Vérifie que les éléments du tableau représentant une url soit ok - * @param array<string,array<string,string>> $url sous forme de tableau - * @return array<string,array<string,string>> url vérifié + * Check that all array elements representing the controller URL are OK + * @param array<string,array<string,string>> $url controller URL as array + * @return array{'c':string,'a':string,'params':array<string,mixed>} Verified controller URL as array */ - public static function checkUrl ($url) { + public static function checkControllerUrl(array $url) { $url_checked = $url; - if (is_array ($url)) { - if (!isset ($url['c'])) { - $url_checked['c'] = Minz_Request::defaultControllerName (); - } - if (!isset ($url['a'])) { - $url_checked['a'] = Minz_Request::defaultActionName (); - } - if (!isset ($url['params'])) { - $url_checked['params'] = array (); - } + if (empty($url['c'])) { + $url_checked['c'] = Minz_Request::defaultControllerName(); + } + if (empty($url['a'])) { + $url_checked['a'] = Minz_Request::defaultActionName(); + } + if (empty($url['params'])) { + $url_checked['params'] = []; } return $url_checked; |
