diff options
| author | 2022-01-01 13:54:36 +0100 | |
|---|---|---|
| committer | 2022-01-01 13:54:36 +0100 | |
| commit | a791388ce4b7b5c03be109418336d41992d93b88 (patch) | |
| tree | e4d0b697887203c1cbd2f19345f52c711354c299 /lib/Minz/Url.php | |
| parent | 3f6aa42b817145a3b00f4d615f87728b55c4413a (diff) | |
Avoid func_get_args (#4108)
Use variadic syntax instead https://php.net/manual/functions.arguments#functions.variable-arg-list
And avoid dynamic functions names when possible to more easily identify calls and unused functions.
Contributes to https://github.com/FreshRSS/FreshRSS/issues/4103
Diffstat (limited to 'lib/Minz/Url.php')
| -rw-r--r-- | lib/Minz/Url.php | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index a1019df50..59afff557 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -118,16 +118,20 @@ class Minz_Url { } } -function _url ($controller, $action) { - $nb_args = func_num_args (); +/** + * @param string $controller + * @param string $action + * @param array<string,string> $args + */ +function _url ($controller, $action, ...$args) { + $nb_args = count($args); - if($nb_args < 2 || $nb_args % 2 != 0) { + if ($nb_args % 2 !== 0) { return false; } - $args = func_get_args (); $params = array (); - for($i = 2; $i < $nb_args; $i = $i + 2) { + for ($i = 0; $i < $nb_args; $i += 2) { $params[$args[$i]] = $args[$i + 1]; } |
