diff --git a/libraries/classes/Navigation/NavigationTree.php b/libraries/classes/Navigation/NavigationTree.php
index 3d5289d4291f..71a38624b221 100644
--- a/libraries/classes/Navigation/NavigationTree.php
+++ b/libraries/classes/Navigation/NavigationTree.php
@@ -215,10 +215,8 @@ public function __construct($template, DatabaseInterface $dbi)
*/
private function getNavigationDbPos(): int
{
- $retval = 0;
-
if (strlen($GLOBALS['db'] ?? '') === 0) {
- return $retval;
+ return 0;
}
/*
@@ -379,14 +377,12 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
return false;
}
- $retval = $db;
-
$containers = $this->addDbContainers($db, $type2, $pos2);
array_shift($path); // remove db
- if ((count($path) <= 0 || ! array_key_exists($path[0], $containers)) && count($containers) != 1) {
- return $retval;
+ if (($path === [] || ! array_key_exists($path[0], $containers)) && count($containers) != 1) {
+ return $db;
}
if (count($containers) === 1) {
@@ -398,8 +394,6 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
}
}
- $retval = $container;
-
if (count($container->children) <= 1) {
$dbData = $db->getData($container->realName, $pos2, $this->searchClause2);
foreach ($dbData as $item) {
@@ -441,7 +435,7 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
array_shift($path); // remove container
if (count($path) <= 0) {
- return $retval;
+ return $container;
}
/** @var NodeTable|null $table */
@@ -458,17 +452,22 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
$container->addChild($node);
$table = $container->getChild($path[0], true);
+ if ($table === null) {
+ return false;
+ }
}
- $retval = $table ?? false;
$containers = $this->addTableContainers($table, $pos2, $type3, $pos3);
array_shift($path); // remove table
- if (count($path) <= 0 || ! array_key_exists($path[0], $containers)) {
- return $retval;
+ if ($path === [] || ! array_key_exists($path[0], $containers)) {
+ return $table;
}
$container = $table->getChild($path[0], true);
- $retval = $container ?? false;
+ if ($container === null) {
+ return false;
+ }
+
$tableData = $table->getData($container->realName, $pos3);
foreach ($tableData as $item) {
switch ($container->realName) {
@@ -497,7 +496,7 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
$container->addChild($node);
}
- return $retval;
+ return $container;
}
/**
@@ -515,7 +514,7 @@ private function buildPathPart(array $path, string $type2, int $pos2, string $ty
* @param int $pos3 The position for the pagination of
* the branch at the third level of the tree
*
- * @return array An array of new nodes
+ * @return Node[] An array of new nodes
*/
private function addTableContainers(NodeTable $table, int $pos2, string $type3, int $pos3): array
{
@@ -568,7 +567,7 @@ private function addTableContainers(NodeTable $table, int $pos2, string $type3,
* @param int $pos2 The position for the pagination of
* the branch at the second level of the tree
*
- * @return array An array of new nodes
+ * @return Node[] An array of new nodes
*/
private function addDbContainers(NodeDatabase $db, string $type, int $pos2): array
{
diff --git a/libraries/classes/Navigation/Nodes/Node.php b/libraries/classes/Navigation/Nodes/Node.php
index 5fb0a5c73e0f..3530ef330ce6 100644
--- a/libraries/classes/Navigation/Nodes/Node.php
+++ b/libraries/classes/Navigation/Nodes/Node.php
@@ -369,7 +369,7 @@ public function getPaths(): array
*
* @return array
*/
- public function getData($type, $pos, $searchClause = '')
+ public function getData(string $type, int $pos, string $searchClause = ''): array
{
if (isset($GLOBALS['cfg']['Server']['DisableIS']) && ! $GLOBALS['cfg']['Server']['DisableIS']) {
return $this->getDataFromInfoSchema($pos, $searchClause);
diff --git a/libraries/classes/Navigation/Nodes/NodeDatabase.php b/libraries/classes/Navigation/Nodes/NodeDatabase.php
index e7ca4f1f57e2..be50ed39a452 100644
--- a/libraries/classes/Navigation/Nodes/NodeDatabase.php
+++ b/libraries/classes/Navigation/Nodes/NodeDatabase.php
@@ -321,7 +321,7 @@ private function getWhereClauseForSearch(
*
* @return array
*/
- public function getData($type, $pos, $searchClause = '')
+ public function getData(string $type, int $pos, string $searchClause = ''): array
{
$pos = (int) $pos;
$retval = [];
diff --git a/libraries/classes/Navigation/Nodes/NodeTable.php b/libraries/classes/Navigation/Nodes/NodeTable.php
index 9856ac2c2779..bb28bb9add5c 100644
--- a/libraries/classes/Navigation/Nodes/NodeTable.php
+++ b/libraries/classes/Navigation/Nodes/NodeTable.php
@@ -148,7 +148,7 @@ public function getPresence($type = '', $searchClause = '')
*
* @return array
*/
- public function getData($type, $pos, $searchClause = '')
+ public function getData(string $type, int $pos, string $searchClause = ''): array
{
$maxItems = $GLOBALS['cfg']['MaxNavigationItems'];
$retval = [];
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 212c5e579fe2..74b74dae6bc9 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -5030,16 +5030,6 @@ parameters:
count: 1
path: libraries/classes/Navigation/NavigationTree.php
- -
- message: "#^Method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:addDbContainers\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/Navigation/NavigationTree.php
-
- -
- message: "#^Method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:addTableContainers\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/Navigation/NavigationTree.php
-
-
message: "#^Method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:buildPathPart\\(\\) has parameter \\$path with no value type specified in iterable type array\\.$#"
count: 1
@@ -5085,6 +5075,11 @@ parameters:
count: 1
path: libraries/classes/Navigation/NavigationTree.php
+ -
+ message: "#^Parameter \\#1 \\$table of method PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:addTableContainers\\(\\) expects PhpMyAdmin\\\\Navigation\\\\Nodes\\\\NodeTable, PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node given\\.$#"
+ count: 1
+ path: libraries/classes/Navigation/NavigationTree.php
+
-
message: "#^Property PhpMyAdmin\\\\Navigation\\\\NavigationTree\\:\\:\\$aPath type has no value type specified in iterable type array\\.$#"
count: 1
@@ -5165,16 +5160,6 @@ parameters:
count: 1
path: libraries/classes/Navigation/Nodes/Node.php
- -
- message: "#^Strict comparison using \\!\\=\\= between PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node and null will always evaluate to true\\.$#"
- count: 1
- path: libraries/classes/Navigation/Nodes/Node.php
-
- -
- message: "#^Unreachable statement \\- code above always terminates\\.$#"
- count: 1
- path: libraries/classes/Navigation/Nodes/Node.php
-
-
message: "#^Method PhpMyAdmin\\\\Navigation\\\\Nodes\\\\NodeColumn\\:\\:__construct\\(\\) has parameter \\$item with no value type specified in iterable type array\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index eeabd3a12ed0..42efa2609e7f 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -8519,6 +8519,9 @@
+
+ $table
+
''
isset($this->pos)
@@ -8529,9 +8532,7 @@
$this->pos3Name
$this->pos3Name
-
- $container->children
- $container->realName
+
$db
$hiddenCounts[$db]
$item
@@ -8558,7 +8559,6 @@
$paths['vPath_clean']
$separator
$separator
- $table
$value
@@ -8577,8 +8577,7 @@
$hiddenCounts[$db]
-
- $container
+
$db
$item
$item
@@ -8586,23 +8585,11 @@
$path
$path
$path
- $retval
- $retval
$separator
$separator
- $table
$urlParams['pos3_name']
$value
-
- Node|bool
-
-
- addChild
- addChild
- getChild
- getChild
-
$separators[0]
$separators[0]
@@ -8612,15 +8599,6 @@
$node
$node
-
- $container->children
- $container->realName
- $container->realName
-
-
- $retval
- $retval
-
strrpos($class, '\\')
strrpos($class, '\\')
@@ -8644,18 +8622,9 @@
$_POST['searchClause']
$_POST['searchClause2']
-
- $container->realName
+
$database
- $table
-
- $container->parent
- $container->realName
-
-
- addChild
-
(int) $GLOBALS['cfg']['FirstLevelNavigationItems']
(int) $GLOBALS['cfg']['FirstLevelNavigationItems']
@@ -8682,6 +8651,9 @@
$_POST['pos2_value'] ?? 0
$_POST['pos3_value']
+
+ $path === []
+