diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 94d98bb4aa..ca602a7ff5 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -9190,11 +9190,6 @@ parameters:
count: 1
path: src/Font.php
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 1
- path: src/Footer.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 4
@@ -9225,11 +9220,6 @@ parameters:
count: 1
path: src/Footer.php
- -
- message: "#^Right side of && is always true\\.$#"
- count: 1
- path: src/Footer.php
-
-
message: "#^Only booleans are allowed in an elseif condition, int\\|false given\\.$#"
count: 1
@@ -9745,11 +9735,6 @@ parameters:
count: 5
path: src/Html/Generator.php
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 1
- path: src/Html/Generator.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 16
@@ -13060,11 +13045,6 @@ parameters:
count: 3
path: src/Plugins/Import/ImportCsv.php
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 1
- path: src/Plugins/Import/ImportCsv.php
-
-
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
count: 1
@@ -13350,11 +13330,6 @@ parameters:
count: 2
path: src/Plugins/Import/ImportShp.php
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 1
- path: src/Plugins/Import/ImportShp.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 2
@@ -14880,11 +14855,6 @@ parameters:
count: 1
path: src/Replication/ReplicationInfo.php
- -
- message: "#^Casting to string something that's already string\\.$#"
- count: 1
- path: src/ResponseRenderer.php
-
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 5
@@ -14900,11 +14870,6 @@ parameters:
count: 1
path: src/ResponseRenderer.php
- -
- message: "#^Right side of && is always true\\.$#"
- count: 1
- path: src/ResponseRenderer.php
-
-
message: "#^Cannot access offset '/' on mixed\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 0482e727ce..ea3bcd3c7d 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -2381,7 +2381,13 @@
getParsedBodyParam('comment')]]>
+ Current::$database
+ Current::$database
+ Current::$database
+
+ Current::$database]]]>
+
@@ -6063,9 +6069,6 @@
$params
-
- Current::$database
-
$info
$subObject
@@ -6084,8 +6087,6 @@
-
-
mixed
@@ -6475,17 +6476,9 @@
$message
-
- Current::$database
- Current::$database
-
strtolower
-
-
-
-
@@ -6515,10 +6508,13 @@
$alt
+ $database
+ $database
$title
$key
+ $database]]]>
@@ -6528,6 +6524,7 @@
$alt
+ $database
$title
$value
@@ -6542,17 +6539,11 @@
$parts[1]
-
- (string) Current::$database
-
-
- isset(Current::$database)
-
@@ -7214,6 +7205,9 @@
$separator
$separator
$value
+ Current::$database
+ Current::$database
+ Current::$database
secondIcon['image']]]>
@@ -7276,9 +7270,6 @@
(string) $key
(string) $key
-
- Current::$database
-
@@ -7289,7 +7280,6 @@
500]]>
-
setHiddenCount
@@ -8697,7 +8687,6 @@
$dbCharset
$dbCollation
$table
- Current::$database
$events
@@ -9153,9 +9142,6 @@
string[]
-
- (string) Current::$database
-
@@ -9385,9 +9371,6 @@
string[]
-
- (string) Current::$database
-
@@ -10710,8 +10693,6 @@
-
-
@@ -12078,12 +12059,6 @@
value]]>
value]]>
-
- Current::$database
-
-
-
-
diff --git a/src/Controllers/Database/EventsController.php b/src/Controllers/Database/EventsController.php
index 6bf1cf9a8f..c4da20126e 100644
--- a/src/Controllers/Database/EventsController.php
+++ b/src/Controllers/Database/EventsController.php
@@ -23,7 +23,6 @@ use function count;
use function htmlspecialchars;
use function mb_strtoupper;
use function sprintf;
-use function strlen;
use function trim;
final class EventsController extends AbstractController
@@ -63,7 +62,7 @@ final class EventsController extends AbstractController
return;
}
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$this->dbi->selectDb(Current::$database);
}
diff --git a/src/Controllers/Database/RoutinesController.php b/src/Controllers/Database/RoutinesController.php
index 98d71f6a31..c41d463335 100644
--- a/src/Controllers/Database/RoutinesController.php
+++ b/src/Controllers/Database/RoutinesController.php
@@ -27,7 +27,6 @@ use function htmlspecialchars;
use function in_array;
use function mb_strtoupper;
use function sprintf;
-use function strlen;
use function trim;
use const ENT_QUOTES;
@@ -110,7 +109,7 @@ class RoutinesController extends AbstractController
return;
}
}
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$this->dbi->selectDb(Current::$database);
}
diff --git a/src/Controllers/Export/ExportController.php b/src/Controllers/Export/ExportController.php
index b4e6562eb5..cb28662f75 100644
--- a/src/Controllers/Export/ExportController.php
+++ b/src/Controllers/Export/ExportController.php
@@ -177,12 +177,12 @@ final class ExportController extends AbstractController
// Generate error url and check for needed variables
if ($GLOBALS['export_type'] === 'server') {
$GLOBALS['errorUrl'] = Url::getFromRoute('/server/export');
- } elseif ($GLOBALS['export_type'] === 'database' && strlen(Current::$database) > 0) {
+ } elseif ($GLOBALS['export_type'] === 'database' && Current::$database !== '') {
$GLOBALS['errorUrl'] = Url::getFromRoute('/database/export', ['db' => Current::$database]);
// Check if we have something to export
$GLOBALS['tables'] = $GLOBALS['table_select'] ?? [];
} elseif (
- $GLOBALS['export_type'] === 'table' && strlen(Current::$database) > 0 && strlen($GLOBALS['table']) > 0
+ $GLOBALS['export_type'] === 'table' && Current::$database !== '' && strlen($GLOBALS['table']) > 0
) {
$GLOBALS['errorUrl'] = Url::getFromRoute('/table/export', [
'db' => Current::$database,
diff --git a/src/Controllers/Import/ImportController.php b/src/Controllers/Import/ImportController.php
index 0054443bd5..53b88efe19 100644
--- a/src/Controllers/Import/ImportController.php
+++ b/src/Controllers/Import/ImportController.php
@@ -248,9 +248,9 @@ final class ImportController extends AbstractController
// We don't want anything special in format
$GLOBALS['format'] = Core::securePath($GLOBALS['format']);
- if (strlen($GLOBALS['table']) > 0 && strlen(Current::$database) > 0) {
+ if (strlen($GLOBALS['table']) > 0 && Current::$database !== '') {
$GLOBALS['urlParams'] = ['db' => Current::$database, 'table' => $GLOBALS['table']];
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$GLOBALS['urlParams'] = ['db' => Current::$database];
} else {
$GLOBALS['urlParams'] = [];
@@ -264,9 +264,9 @@ final class ImportController extends AbstractController
} elseif ($GLOBALS['import_type'] === 'server') {
$GLOBALS['goto'] = Url::getFromRoute('/server/import');
} elseif (empty($GLOBALS['goto']) || ! preg_match('@^index\.php$@i', $GLOBALS['goto'])) {
- if (strlen($GLOBALS['table']) > 0 && strlen(Current::$database) > 0) {
+ if (strlen($GLOBALS['table']) > 0 && Current::$database !== '') {
$GLOBALS['goto'] = Url::getFromRoute('/table/structure');
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$GLOBALS['goto'] = Url::getFromRoute('/database/structure');
} else {
$GLOBALS['goto'] = Url::getFromRoute('/server/sql');
@@ -276,7 +276,7 @@ final class ImportController extends AbstractController
$GLOBALS['errorUrl'] = $GLOBALS['goto'] . Url::getCommon($GLOBALS['urlParams'], '&');
$_SESSION['Import_message']['go_back_url'] = $GLOBALS['errorUrl'];
- if (strlen(Current::$database) > 0) {
+ if (Current::$database !== '') {
$this->dbi->selectDb(Current::$database);
}
diff --git a/src/Controllers/Operations/DatabaseController.php b/src/Controllers/Operations/DatabaseController.php
index 3fbaf365b2..34822cda4a 100644
--- a/src/Controllers/Operations/DatabaseController.php
+++ b/src/Controllers/Operations/DatabaseController.php
@@ -28,7 +28,6 @@ use PhpMyAdmin\Util;
use function __;
use function mb_strtolower;
-use function strlen;
/**
* Handles miscellaneous database operations.
@@ -66,7 +65,7 @@ class DatabaseController extends AbstractController
* Rename/move or copy database
*/
if (
- strlen(Current::$database) > 0 && ($request->hasBodyParam('db_rename') || $request->hasBodyParam('db_copy'))
+ Current::$database !== '' && ($request->hasBodyParam('db_rename') || $request->hasBodyParam('db_copy'))
) {
$move = $request->hasBodyParam('db_rename');
diff --git a/src/Controllers/Sql/SqlController.php b/src/Controllers/Sql/SqlController.php
index 30bcb42621..8615e022af 100644
--- a/src/Controllers/Sql/SqlController.php
+++ b/src/Controllers/Sql/SqlController.php
@@ -127,7 +127,7 @@ class SqlController extends AbstractController
// Default to browse if no query set and we have table
// (needed for browsing from DefaultTabTable)
- if (empty($GLOBALS['sql_query']) && strlen($GLOBALS['table']) > 0 && strlen(Current::$database) > 0) {
+ if (empty($GLOBALS['sql_query']) && strlen($GLOBALS['table']) > 0 && Current::$database !== '') {
$GLOBALS['sql_query'] = $this->sql->getDefaultSqlQueryForBrowse(Current::$database, $GLOBALS['table']);
// set $goto to what will be displayed if query returns 0 rows
diff --git a/src/Controllers/Table/ChartController.php b/src/Controllers/Table/ChartController.php
index fd1c126b4b..70ac297131 100644
--- a/src/Controllers/Table/ChartController.php
+++ b/src/Controllers/Table/ChartController.php
@@ -51,7 +51,8 @@ class ChartController extends AbstractController
if (isset($_REQUEST['pos'], $_REQUEST['session_max_rows']) && $request->isAjax()) {
if (
strlen($GLOBALS['table']) > 0
- && strlen(Current::$database) > 0 && ! $this->checkParameters(['db', 'table'])
+ && Current::$database !== ''
+ && ! $this->checkParameters(['db', 'table'])
) {
return;
}
@@ -132,7 +133,7 @@ class ChartController extends AbstractController
$urlParams['goto'] = Util::getScriptNameForOption($config->settings['DefaultTabTable'], 'table');
$urlParams['back'] = Url::getFromRoute('/table/sql');
$this->dbi->selectDb(Current::$database);
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$urlParams['goto'] = Util::getScriptNameForOption($config->settings['DefaultTabDatabase'], 'database');
$urlParams['back'] = Url::getFromRoute('/sql');
@@ -221,7 +222,7 @@ class ChartController extends AbstractController
{
$GLOBALS['urlParams'] ??= null;
$GLOBALS['errorUrl'] ??= null;
- if (strlen($GLOBALS['table']) > 0 && strlen(Current::$database) > 0) {
+ if (strlen($GLOBALS['table']) > 0 && Current::$database !== '') {
$GLOBALS['urlParams'] = ['db' => Current::$database, 'table' => $GLOBALS['table']];
$GLOBALS['errorUrl'] = Util::getScriptNameForOption(
Config::getInstance()->settings['DefaultTabTable'],
diff --git a/src/Controllers/Triggers/IndexController.php b/src/Controllers/Triggers/IndexController.php
index 90ea8bdb2b..36e2d26993 100644
--- a/src/Controllers/Triggers/IndexController.php
+++ b/src/Controllers/Triggers/IndexController.php
@@ -27,7 +27,6 @@ use function htmlspecialchars;
use function in_array;
use function mb_strtoupper;
use function sprintf;
-use function strlen;
use function trim;
/**
@@ -103,7 +102,7 @@ final class IndexController extends AbstractController
return;
}
}
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$this->dbi->selectDb(Current::$database);
}
diff --git a/src/Footer.php b/src/Footer.php
index 3e858b96ba..687856137f 100644
--- a/src/Footer.php
+++ b/src/Footer.php
@@ -131,7 +131,7 @@ class Footer
$params = [];
$params['route'] = Routing::$route;
- if (isset(Current::$database) && strlen(Current::$database) > 0) {
+ if (Current::$database !== '') {
$params['db'] = Current::$database;
}
@@ -186,7 +186,7 @@ class Footer
}
$this->relation->setHistory(
- isset(Current::$database) && is_scalar(Current::$database) ? (string) Current::$database : '',
+ Current::$database,
isset($GLOBALS['table']) && is_scalar($GLOBALS['table']) ? (string) $GLOBALS['table'] : '',
Config::getInstance()->selectedServer['user'],
$GLOBALS['sql_query'],
diff --git a/src/Header.php b/src/Header.php
index 5a8b17e38a..547a9e320c 100644
--- a/src/Header.php
+++ b/src/Header.php
@@ -90,7 +90,7 @@ class Header
$dbi = DatabaseInterface::getInstance();
$this->console = $console;
$this->menuEnabled = $dbi->isConnected();
- $this->menu = new Menu($dbi, $this->template, Current::$database ?? '', $GLOBALS['table'] ?? '');
+ $this->menu = new Menu($dbi, $this->template, Current::$database, $GLOBALS['table'] ?? '');
$this->scripts = new Scripts($this->template);
$this->addDefaultScripts();
@@ -138,7 +138,7 @@ class Header
'lang' => $GLOBALS['lang'],
'server' => $GLOBALS['server'],
'table' => $GLOBALS['table'] ?? '',
- 'db' => Current::$database ?? '',
+ 'db' => Current::$database,
'token' => $_SESSION[' PMA_token '],
'text_dir' => $GLOBALS['text_dir'],
'LimitChars' => $config->settings['LimitChars'],
diff --git a/src/Html/Generator.php b/src/Html/Generator.php
index 4b26c6b601..62997dac1c 100644
--- a/src/Html/Generator.php
+++ b/src/Html/Generator.php
@@ -130,7 +130,7 @@ class Generator
public static function getDbLink(string $database): string
{
if ($database === '') {
- if ((string) Current::$database === '') {
+ if (Current::$database === '') {
return '';
}
@@ -494,11 +494,7 @@ class Generator
// Basic url query part
$urlParams = [];
- if (! isset(Current::$database)) {
- Current::$database = '';
- }
-
- if (strlen(Current::$database) > 0) {
+ if (Current::$database !== '') {
$urlParams['db'] = Current::$database;
if (strlen($GLOBALS['table']) > 0) {
$urlParams['table'] = $GLOBALS['table'];
@@ -806,7 +802,7 @@ class Generator
$urlParams['db'] = Current::$database;
$urlParams['table'] = $GLOBALS['table'];
$doEditGoto = '';
- } elseif (strlen(Current::$database) > 0) {
+ } elseif (Current::$database !== '') {
$urlParams['db'] = Current::$database;
$doEditGoto = '';
} else {
diff --git a/src/ListDatabase.php b/src/ListDatabase.php
index 16ae9ba9df..ad973cac21 100644
--- a/src/ListDatabase.php
+++ b/src/ListDatabase.php
@@ -171,7 +171,7 @@ class ListDatabase extends ListAbstract
*/
public function getDefault(): string
{
- if (strlen(Current::$database) > 0) {
+ if (Current::$database !== '') {
return Current::$database;
}
diff --git a/src/Navigation/NavigationTree.php b/src/Navigation/NavigationTree.php
index 263b173931..8ddf641d75 100644
--- a/src/Navigation/NavigationTree.php
+++ b/src/Navigation/NavigationTree.php
@@ -221,7 +221,7 @@ class NavigationTree
*/
private function getNavigationDbPos(): int
{
- if ((Current::$database ?? '') === '') {
+ if (Current::$database === '') {
return 0;
}
diff --git a/src/Plugins/Auth/AuthenticationCookie.php b/src/Plugins/Auth/AuthenticationCookie.php
index 5aaf4ab525..596abcecbb 100644
--- a/src/Plugins/Auth/AuthenticationCookie.php
+++ b/src/Plugins/Auth/AuthenticationCookie.php
@@ -456,7 +456,7 @@ class AuthenticationCookie extends AuthenticationPlugin
// any parameters to pass?
$urlParams = [];
- if (strlen(Current::$database) > 0) {
+ if (Current::$database !== '') {
$urlParams['db'] = Current::$database;
}
diff --git a/src/Plugins/Export/ExportXml.php b/src/Plugins/Export/ExportXml.php
index 55eb67cab0..8b4c91425e 100644
--- a/src/Plugins/Export/ExportXml.php
+++ b/src/Plugins/Export/ExportXml.php
@@ -26,7 +26,6 @@ use function is_array;
use function mb_substr;
use function rtrim;
use function str_replace;
-use function strlen;
use const PHP_VERSION;
@@ -520,6 +519,6 @@ class ExportXml extends ExportPlugin
public static function isAvailable(): bool
{
// Can't do server export.
- return isset(Current::$database) && strlen(Current::$database) > 0;
+ return Current::$database !== '';
}
}
diff --git a/src/Plugins/Import/ImportCsv.php b/src/Plugins/Import/ImportCsv.php
index 74e78a81d2..c920fa8ab7 100644
--- a/src/Plugins/Import/ImportCsv.php
+++ b/src/Plugins/Import/ImportCsv.php
@@ -582,7 +582,7 @@ class ImportCsv extends AbstractImportCsv
array_shift($rows);
}
- $tblName = $this->getTableNameFromImport((string) Current::$database);
+ $tblName = $this->getTableNameFromImport(Current::$database);
$tables[] = [$tblName, $colNames, $rows];
diff --git a/src/Plugins/Import/ImportShp.php b/src/Plugins/Import/ImportShp.php
index e3aa5f4a90..f303d5bfe6 100644
--- a/src/Plugins/Import/ImportShp.php
+++ b/src/Plugins/Import/ImportShp.php
@@ -261,7 +261,7 @@ class ImportShp extends ImportPlugin
}
// Set table name based on the number of tables
- if (strlen((string) Current::$database) > 0) {
+ if (Current::$database !== '') {
$result = DatabaseInterface::getInstance()->fetchResult('SHOW TABLES');
$tableName = 'TABLE ' . (count($result) + 1);
} else {
diff --git a/src/ResponseRenderer.php b/src/ResponseRenderer.php
index 71eedb1a8c..c86557d949 100644
--- a/src/ResponseRenderer.php
+++ b/src/ResponseRenderer.php
@@ -329,8 +329,7 @@ class ResponseRenderer
$this->addJSON(
'reloadQuerywindow',
[
- 'db' => isset(Current::$database) && is_scalar(Current::$database)
- ? (string) Current::$database : '',
+ 'db' => Current::$database,
'table' => isset($GLOBALS['table']) && is_scalar($GLOBALS['table'])
? (string) $GLOBALS['table'] : '',
'sql_query' => $query,
diff --git a/src/Tracking/Tracker.php b/src/Tracking/Tracker.php
index f6bcd1c6bd..8f90ebdb83 100644
--- a/src/Tracking/Tracker.php
+++ b/src/Tracking/Tracker.php
@@ -560,7 +560,7 @@ class Tracker
}
// Get database name
- $dbname = trim(Current::$database ?? '', '`');
+ $dbname = trim(Current::$database, '`');
// $dbname can be empty, for example when coming from Synchronize
// and this is a query for the remote server
if ($dbname === '') {