From 477e867cab7e191877e124ce326195d61c60e746 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sat, 27 May 2023 23:15:12 +0100 Subject: [PATCH] More specific return type Signed-off-by: Kamil Tekiela --- libraries/classes/Navigation/NavigationTree.php | 10 +++------- phpstan-baseline.neon | 5 +++++ psalm-baseline.xml | 6 ++++++ 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/libraries/classes/Navigation/NavigationTree.php b/libraries/classes/Navigation/NavigationTree.php index 14b24ee534..c00c77866e 100644 --- a/libraries/classes/Navigation/NavigationTree.php +++ b/libraries/classes/Navigation/NavigationTree.php @@ -40,6 +40,7 @@ use function _ngettext; use function array_intersect_key; use function array_key_exists; use function array_keys; +use function array_map; use function array_merge; use function array_shift; use function base64_decode; @@ -289,16 +290,11 @@ class NavigationTree * * @param string $string The path to parse * - * @return mixed[] + * @return non-empty-list */ private function parsePath(string $string): array { - $path = explode('.', $string); - foreach ($path as $key => $value) { - $path[$key] = base64_decode($value); - } - - return $path; + return array_map(base64_decode(...), explode('.', $string)); } /** diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9aafd09bea..e6bcb7826c 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4675,6 +4675,11 @@ parameters: count: 1 path: libraries/classes/Navigation/NavigationTree.php + - + message: "#^Method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:parsePath\\(\\) should return non\\-empty\\-array\\ but returns non\\-empty\\-array\\\\.$#" + count: 1 + path: libraries/classes/Navigation/NavigationTree.php + - message: "#^Only numeric types are allowed in \\+, int\\|false given on the left side\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5d39590c72..752717947d 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -7687,6 +7687,12 @@ pos3Name]]> pos3Name]]> + + + + + ]]> + $db $item