From 48cd962475b931f181cdfb2f7e24327e3964b59d Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Tue, 5 Dec 2023 15:56:51 +0100 Subject: [PATCH] Fix type hint in exportDatabase() Signed-off-by: Kamil Tekiela t --- phpstan-baseline.neon | 35 +++++------------------------------ psalm-baseline.xml | 3 --- src/Export/Export.php | 12 ++++++------ 3 files changed, 11 insertions(+), 39 deletions(-) diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 62d2ac0857..014ab3d1d9 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -3226,7 +3226,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -3301,7 +3301,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#4 \\$tableStructure of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#4 \\$tableStructure of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -3321,7 +3321,7 @@ parameters: path: src/Controllers/Export/ExportController.php - - message: "#^Parameter \\#5 \\$tableData of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array, mixed given\\.$#" + message: "#^Parameter \\#5 \\$tableData of method PhpMyAdmin\\\\Export\\\\Export\\:\\:exportDatabase\\(\\) expects array\\, mixed given\\.$#" count: 2 path: src/Controllers/Export/ExportController.php @@ -10267,7 +10267,7 @@ parameters: - message: "#^Call to function in_array\\(\\) requires parameter \\#3 to be set\\.$#" - count: 5 + count: 2 path: src/Export/Export.php - @@ -10332,12 +10332,7 @@ parameters: - message: "#^Parameter \\#1 \\$identifier of static method PhpMyAdmin\\\\Util\\:\\:backquote\\(\\) expects string\\|Stringable\\|null, mixed given\\.$#" - count: 2 - path: src/Export/Export.php - - - - message: "#^Parameter \\#1 \\$name of class PhpMyAdmin\\\\Table\\\\Table constructor expects string, mixed given\\.$#" - count: 2 + count: 1 path: src/Export/Export.php - @@ -10345,11 +10340,6 @@ parameters: count: 2 path: src/Export/Export.php - - - message: "#^Parameter \\#1 \\$str of method PhpMyAdmin\\\\DatabaseInterface\\:\\:quoteString\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Export/Export.php - - message: "#^Parameter \\#1 \\$stream of function fwrite expects resource, mixed given\\.$#" count: 2 @@ -10370,21 +10360,6 @@ parameters: count: 1 path: src/Export/Export.php - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportData\\(\\) expects string, mixed given\\.$#" - count: 1 - path: src/Export/Export.php - - - - message: "#^Parameter \\#2 \\$table of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportStructure\\(\\) expects string, mixed given\\.$#" - count: 4 - path: src/Export/Export.php - - - - message: "#^Parameter \\#2 \\$tables of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportMetadata\\(\\) expects array\\\\|string, array given\\.$#" - count: 1 - path: src/Export/Export.php - - message: "#^Parameter \\#3 \\$dbAlias of method PhpMyAdmin\\\\Plugins\\\\ExportPlugin\\:\\:exportDBCreate\\(\\) expects string, mixed given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e1b9fa4439..31fd975898 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -5952,11 +5952,9 @@ $dbAlias $dbAlias $table - $table $dbSelect - $tables getName()]['alias']]]> @@ -5987,7 +5985,6 @@ $dbAlias $dbAlias $table - $table $tableName $tbl $val diff --git a/src/Export/Export.php b/src/Export/Export.php index ba98d1f35e..6e45fb6956 100644 --- a/src/Export/Export.php +++ b/src/Export/Export.php @@ -599,10 +599,10 @@ class Export * Export at the database level * * @param DatabaseName $db the database to export - * @param mixed[] $tables the tables to export + * @param string[] $tables the tables to export * @param string $whatStrucOrData structure or data or both - * @param mixed[] $tableStructure whether to export structure for each table - * @param mixed[] $tableData whether to export data for each table + * @param string[] $tableStructure whether to export structure for each table + * @param string[] $tableData whether to export data for each table * @param ExportPlugin $exportPlugin the selected export plugin * @param string $errorUrl the URL in case of error * @param string $exportType the export type @@ -677,7 +677,7 @@ class Export if ( ($whatStrucOrData === 'structure' || $whatStrucOrData === 'structure_and_data') - && in_array($table, $tableStructure) + && in_array($table, $tableStructure, true) ) { // for a view, export a stand-in definition of the table // to resolve view dependencies (only when it's a single-file export) @@ -739,7 +739,7 @@ class Export // if this is a view or a merge table, don't export data if ( ($whatStrucOrData === 'data' || $whatStrucOrData === 'structure_and_data') - && in_array($table, $tableData) + && in_array($table, $tableData, true) && ! $isView ) { $tableObj = new Table($table, $db->getName(), $this->dbi); @@ -764,7 +764,7 @@ class Export if ( ! isset($GLOBALS['sql_create_trigger']) || ($whatStrucOrData !== 'structure' && $whatStrucOrData !== 'structure_and_data') - || ! in_array($table, $tableStructure) + || ! in_array($table, $tableStructure, true) ) { continue; }