Skip to content

Commit 8bb3125

Browse files
Merge pull request #18464 from kamil-tekiela/Refactor-parsePath
More specific return type
2 parents bc553ff + 477e867 commit 8bb3125

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

libraries/classes/Navigation/NavigationTree.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use function array_intersect_key;
4141
use function array_key_exists;
4242
use function array_keys;
43+
use function array_map;
4344
use function array_merge;
4445
use function array_shift;
4546
use function base64_decode;
@@ -289,16 +290,11 @@ private function getNavigationDbPos(): int
289290
*
290291
* @param string $string The path to parse
291292
*
292-
* @return mixed[]
293+
* @return non-empty-list<string>
293294
*/
294295
private function parsePath(string $string): array
295296
{
296-
$path = explode('.', $string);
297-
foreach ($path as $key => $value) {
298-
$path[$key] = base64_decode($value);
299-
}
300-
301-
return $path;
297+
return array_map(base64_decode(...), explode('.', $string));
302298
}
303299

304300
/**

phpstan-baseline.neon

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4640,6 +4640,11 @@ parameters:
46404640
count: 1
46414641
path: libraries/classes/Navigation/NavigationTree.php
46424642

4643+
-
4644+
message: "#^Method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:parsePath\\(\\) should return non\\-empty\\-array\\<int, string\\> but returns non\\-empty\\-array\\<int, string\\|false\\>\\.$#"
4645+
count: 1
4646+
path: libraries/classes/Navigation/NavigationTree.php
4647+
46434648
-
46444649
message: "#^Only numeric types are allowed in \\+, int\\|false given on the left side\\.$#"
46454650
count: 1

psalm-baseline.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7657,6 +7657,12 @@
76577657
<code><![CDATA[$this->pos3Name]]></code>
76587658
<code><![CDATA[$this->pos3Name]]></code>
76597659
</InvalidPropertyAssignmentValue>
7660+
<InvalidReturnStatement>
7661+
<code><![CDATA[array_map(base64_decode(...), explode('.', $string))]]></code>
7662+
</InvalidReturnStatement>
7663+
<InvalidReturnType>
7664+
<code><![CDATA[non-empty-list<string>]]></code>
7665+
</InvalidReturnType>
76607666
<MixedArgument>
76617667
<code>$db</code>
76627668
<code>$item</code>

0 commit comments

Comments
 (0)