From a72ec07b68b279e52dc7eda5b3a5ee4e968849e8 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Sun, 28 May 2023 00:08:45 +0100 Subject: [PATCH] Use array shape for getPaths Signed-off-by: Kamil Tekiela --- .../classes/Navigation/NavigationTree.php | 6 ++--- libraries/classes/Navigation/Nodes/Node.php | 2 +- phpstan-baseline.neon | 25 ------------------- psalm-baseline.xml | 6 ----- 4 files changed, 4 insertions(+), 35 deletions(-) diff --git a/libraries/classes/Navigation/NavigationTree.php b/libraries/classes/Navigation/NavigationTree.php index 14b24ee534..9c39727ef9 100644 --- a/libraries/classes/Navigation/NavigationTree.php +++ b/libraries/classes/Navigation/NavigationTree.php @@ -955,13 +955,13 @@ class NavigationTree $paths = $node->getPaths(); if (isset($paths['aPath_clean'][2])) { $renderDetails['position'] = 'pos2_nav'; - $renderDetails['data_name'] = (string) $paths['aPath_clean'][2]; + $renderDetails['data_name'] = $paths['aPath_clean'][2]; $renderDetails['data_value'] = (string) $node->pos2; } if (isset($paths['aPath_clean'][4])) { $renderDetails['position'] = 'pos3_nav'; - $renderDetails['data_name'] = (string) $paths['aPath_clean'][4]; + $renderDetails['data_name'] = $paths['aPath_clean'][4]; $renderDetails['data_value'] = (string) $node->pos3; } @@ -1157,7 +1157,7 @@ class NavigationTree 'pagination_params' => $paginationParams, 'node_is_group' => $nodeIsGroup ?? false, 'link_classes' => $linkClasses ?? '', - 'paths' => ['a_path' => $paths['aPath'] ?? '', 'v_path' => $paths['vPath'] ?? '', 'pos' => $this->pos], + 'paths' => ['a_path' => $paths['aPath'], 'v_path' => $paths['vPath'], 'pos' => $this->pos], 'node_icon' => $nodeIcon ?? '', ]); } diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php index 00dbc757c9..79fe155398 100644 --- a/libraries/classes/Navigation/Nodes/Node.php +++ b/libraries/classes/Navigation/Nodes/Node.php @@ -313,7 +313,7 @@ class Node * Returns the actual path and the virtual paths for a node * both as clean arrays and base64 encoded strings * - * @return mixed[] + * @return array{aPath: string, aPath_clean: string[], vPath: string, vPath_clean: string[]} */ public function getPaths(): array { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 9aafd09bea..d91e65fa2d 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -4640,16 +4640,6 @@ parameters: count: 2 path: libraries/classes/Navigation/NavigationTree.php - - - message: "#^Cannot access offset 2 on mixed\\.$#" - count: 2 - path: libraries/classes/Navigation/NavigationTree.php - - - - message: "#^Cannot access offset 4 on mixed\\.$#" - count: 1 - path: libraries/classes/Navigation/NavigationTree.php - - message: "#^Cannot access property \\$pos2 on PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\|null\\.$#" count: 1 @@ -4660,11 +4650,6 @@ parameters: count: 1 path: libraries/classes/Navigation/NavigationTree.php - - - message: "#^Cannot cast mixed to string\\.$#" - count: 1 - path: libraries/classes/Navigation/NavigationTree.php - - message: "#^Casting to string something that's already string\\.$#" count: 4 @@ -4720,11 +4705,6 @@ parameters: count: 10 path: libraries/classes/Navigation/NavigationTree.php - - - message: "#^Parameter \\#2 \\$paths of method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:findTreeMatch\\(\\) expects array, mixed given\\.$#" - count: 1 - path: libraries/classes/Navigation/NavigationTree.php - - message: "#^Parameter \\#2 \\$searchClause of method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\NodeDatabase\\:\\:getPresence\\(\\) expects string, mixed given\\.$#" count: 1 @@ -4735,11 +4715,6 @@ parameters: count: 1 path: libraries/classes/Navigation/Nodes/Node.php - - - message: "#^Parameter \\#1 \\$value of function count expects array\\|Countable, mixed given\\.$#" - count: 1 - path: libraries/classes/Navigation/Nodes/Node.php - - message: "#^Parameter \\#2 \\.\\.\\.\\$values of function sprintf expects bool\\|float\\|int\\|string\\|null, mixed given\\.$#" count: 3 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 5d39590c72..ab3dcda5db 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -7709,7 +7709,6 @@ $path[0] $path[0] $path[0] - $separator $separator $value @@ -7717,9 +7716,6 @@ secondIcon['image']]]> secondIcon['title']]]> - - - $db @@ -7731,7 +7727,6 @@ $path $separator $separator - $value @@ -7825,7 +7820,6 @@ $db $db $db - $child