diff options
| author | 2023-04-17 08:30:21 +0200 | |
|---|---|---|
| committer | 2023-04-17 08:30:21 +0200 | |
| commit | f3760f138dcbaf7a2190336a0378cf1b2190c9f5 (patch) | |
| tree | 6fac8fbf9efd7aa74a8e3970ab70ccf85287b2cd /lib/Minz/Url.php | |
| parent | 41fa4e746df8c2e2399ed753b4994ca85cb21358 (diff) | |
Complete PHPStan Level 6 (#5305)
* Complete PHPStan Level 6
Fix https://github.com/FreshRSS/FreshRSS/issues/4112
And initiate PHPStan Level 7
* PHPStan Level 6 for tests
* Use phpstan/phpstan-phpunit
* Update to PHPStan version 1.10
* Fix mixed bug
* Fix mixed return bug
* Fix paginator bug
* Fix FreshRSS_UserConfiguration
* A couple more Minz_Configuration bug fixes
* A few trivial PHPStan Level 7 fixes
* A few more simple PHPStan Level 7
* More files passing PHPStan Level 7
Add interface to replace removed class from https://github.com/FreshRSS/FreshRSS/pull/5251
* A few more PHPStan Level 7 preparations
* A few last details
Diffstat (limited to 'lib/Minz/Url.php')
| -rw-r--r-- | lib/Minz/Url.php | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/lib/Minz/Url.php b/lib/Minz/Url.php index 1350973c1..f0df93b69 100644 --- a/lib/Minz/Url.php +++ b/lib/Minz/Url.php @@ -60,7 +60,7 @@ class Minz_Url { * @param string $encodage pour indiquer comment encoder les & (& ou & pour html) * @return string uri sous la forme ?key=value&key2=value2 */ - private static function printUri($url, string $encodage): string { + private static function printUri(array $url, string $encodage): string { $uri = ''; $separator = '?'; $anchor = ''; @@ -108,23 +108,15 @@ class Minz_Url { /** * Check that all array elements representing the controller URL are OK - * @param array<string,array<string,string>> $url controller URL as array + * @param array<string,string|array<string,mixed>> $url controller URL as array * @return array{'c':string,'a':string,'params':array<string,mixed>} Verified controller URL as array */ - public static function checkControllerUrl(array $url) { - $url_checked = $url; - - 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; + public static function checkControllerUrl(array $url): array { + return [ + 'c' => empty($url['c']) || !is_string($url['c']) ? Minz_Request::defaultControllerName() : $url['c'], + 'a' => empty($url['a']) || !is_string($url['a']) ? Minz_Request::defaultActionName() : $url['a'], + 'params' => empty($url['params']) || !is_array($url['params']) ? [] : $url['params'], + ]; } /** @param array<string,string|array<string,string>>|null $url */ @@ -139,7 +131,10 @@ class Minz_Url { } } - /** @return array<string,string|array<string,string>> */ + /** + * @phpstan-return array{'c'?:string,'a'?:string,'params'?:array<string,mixed>} + * @return array<string,string|array<string,string>> + */ public static function unserialize(string $url = ''): array { try { return json_decode(base64_decode($url), true, JSON_THROW_ON_ERROR) ?? []; @@ -150,7 +145,7 @@ class Minz_Url { /** * Returns an array representing the URL as passed in the address bar - * @return array<string,string|array<string,string>> URL representation + * @return array{'c'?:string,'a'?:string,'params'?:array<string,mixed>} URL representation */ public static function build(): array { $url = [ |
