diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 20f67c43d3..6ed1244adb 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -7764,24 +7764,6 @@ parameters: count: 8 path: src/Navigation/Nodes/Node.php - - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - identifier: empty.notAllowed - count: 4 - path: src/Navigation/Nodes/Node.php - - - - message: '#^Method PhpMyAdmin\\Navigation\\Nodes\\Node\:\:getDatabasesToSearch\(\) should return array\ but returns list\\|string\.$#' - identifier: return.type - count: 1 - path: src/Navigation/Nodes/Node.php - - - - message: '#^Parameter \#1 \$array of function sort expects TArray of array\, array\\|string given\.$#' - identifier: argument.type - count: 1 - path: src/Navigation/Nodes/Node.php - - message: '#^Parameter \#1 \$db of method PhpMyAdmin\\Navigation\\Nodes\\Node\:\:isHideDb\(\) expects string, string\|null given\.$#' identifier: argument.type @@ -7794,12 +7776,6 @@ parameters: count: 4 path: src/Navigation/Nodes/Node.php - - - message: '#^Parameter \#1 \$str of method PhpMyAdmin\\Dbal\\DatabaseInterface\:\:quoteString\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 5 - path: src/Navigation/Nodes/Node.php - - message: '#^Binary operation "\." between mixed and ''\)'' results in an error\.$#' identifier: binaryOp.invalid @@ -16353,12 +16329,6 @@ parameters: count: 7 path: tests/unit/Navigation/Nodes/NodeTest.php - - - message: '#^Property PhpMyAdmin\\Config\:\:\$selectedServer \(array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\) does not accept array\{host\: string, port\: string, socket\: string, ssl\: bool, ssl_key\: string\|null, ssl_cert\: string\|null, ssl_ca\: string\|null, ssl_ca_path\: string\|null, \.\.\.\}\.$#' - identifier: assign.propertyType - count: 3 - path: tests/unit/Navigation/Nodes/NodeTest.php - - message: ''' #^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\: diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 33d87ad891..7617f5385e 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5276,23 +5276,6 @@ - - - - - - - - - - - - - - - - - @@ -5312,12 +5295,6 @@ - - config->selectedServer['hide_db'])]]> - config->selectedServer['hide_db'])]]> - config->selectedServer['only_db'])]]> - config->selectedServer['only_db'])]]> - @@ -10518,10 +10495,6 @@ - - selectedServer]]> - selectedServer]]> - diff --git a/src/Navigation/Nodes/Node.php b/src/Navigation/Nodes/Node.php index 7e28f0599f..73fe5b6c12 100644 --- a/src/Navigation/Nodes/Node.php +++ b/src/Navigation/Nodes/Node.php @@ -434,7 +434,7 @@ class Node */ private function isHideDb(string $db): bool { - return ! empty($this->config->selectedServer['hide_db']) + return $this->config->selectedServer['hide_db'] !== '' && preg_match('/' . $this->config->selectedServer['hide_db'] . '/', $db) === 1; } @@ -446,15 +446,15 @@ class Node * * @param string $searchClause search clause * - * @return mixed[] array of databases + * @return string[] array of databases */ private function getDatabasesToSearch(UserPrivileges $userPrivileges, string $searchClause): array { $databases = []; if ($searchClause !== '') { $databases = ['%' . DatabaseInterface::getInstance()->escapeMysqlWildcards($searchClause) . '%']; - } elseif (! empty($this->config->selectedServer['only_db'])) { - $databases = $this->config->selectedServer['only_db']; + } elseif ($this->config->selectedServer['only_db'] !== '') { + $databases = (array) $this->config->selectedServer['only_db']; } elseif ($userPrivileges->databasesToTest !== false && $userPrivileges->databasesToTest !== []) { $databases = $userPrivileges->databasesToTest; } @@ -480,12 +480,12 @@ class Node . ' LIKE ' . $dbi->quoteString('%' . $dbi->escapeMysqlWildcards($searchClause) . '%') . ' '; } - if (! empty($this->config->selectedServer['hide_db'])) { + if ($this->config->selectedServer['hide_db'] !== '') { $whereClause .= 'AND ' . Util::backquote($columnName) . ' NOT REGEXP ' . $dbi->quoteString($this->config->selectedServer['hide_db']) . ' '; } - if (! empty($this->config->selectedServer['only_db'])) { + if ($this->config->selectedServer['only_db'] !== '') { if (is_string($this->config->selectedServer['only_db'])) { $this->config->selectedServer['only_db'] = [$this->config->selectedServer['only_db']]; } diff --git a/tests/unit/Navigation/Nodes/NodeTest.php b/tests/unit/Navigation/Nodes/NodeTest.php index 86c2f2183c..bfa0076c2a 100644 --- a/tests/unit/Navigation/Nodes/NodeTest.php +++ b/tests/unit/Navigation/Nodes/NodeTest.php @@ -295,7 +295,7 @@ final class NodeTest extends AbstractTestCase "WHERE TRUE AND `SCHEMA_NAME` NOT REGEXP 'regexpHideDb' ", $method->invoke($node, 'SCHEMA_NAME'), ); - unset($config->selectedServer['hide_db']); + $config->selectedServer['hide_db'] = ''; // When only_db directive is present and it's a single db $config->selectedServer['only_db'] = 'stringOnlyDb'; @@ -303,7 +303,7 @@ final class NodeTest extends AbstractTestCase "WHERE TRUE AND ( `SCHEMA_NAME` LIKE 'stringOnlyDb' ) ", $method->invoke($node, 'SCHEMA_NAME'), ); - unset($config->selectedServer['only_db']); + $config->selectedServer['only_db'] = ''; // When only_db directive is present and it's an array of dbs $config->selectedServer['only_db'] = ['onlyDbOne', 'onlyDbTwo']; @@ -311,7 +311,7 @@ final class NodeTest extends AbstractTestCase 'WHERE TRUE AND ( `SCHEMA_NAME` LIKE \'onlyDbOne\' OR `SCHEMA_NAME` LIKE \'onlyDbTwo\' ) ', $method->invoke($node, 'SCHEMA_NAME'), ); - unset($config->selectedServer['only_db']); + $config->selectedServer['only_db'] = ''; } /**