diff --git a/libraries/classes/DatabaseInterface.php b/libraries/classes/DatabaseInterface.php
index cec845d427..f2bccb3eb4 100644
--- a/libraries/classes/DatabaseInterface.php
+++ b/libraries/classes/DatabaseInterface.php
@@ -1472,7 +1472,7 @@ class DatabaseInterface implements DbalInterface
* @param string $which PROCEDURE | FUNCTION
* @param int $link link type
*
- * @return array the procedure names or function names
+ * @return string[] the procedure names or function names
*/
public function getProceduresOrFunctions(
string $db,
diff --git a/libraries/classes/Dbal/DbalInterface.php b/libraries/classes/Dbal/DbalInterface.php
index ebd462b6de..8b54935871 100644
--- a/libraries/classes/Dbal/DbalInterface.php
+++ b/libraries/classes/Dbal/DbalInterface.php
@@ -436,7 +436,7 @@ interface DbalInterface
* @param string $which PROCEDURE | FUNCTION
* @param int $link link type
*
- * @return array the procedure names or function names
+ * @return string[] the procedure names or function names
*/
public function getProceduresOrFunctions(
string $db,
diff --git a/libraries/classes/Plugins/Export/ExportXml.php b/libraries/classes/Plugins/Export/ExportXml.php
index 3241eaf2bc..349fe0abc2 100644
--- a/libraries/classes/Plugins/Export/ExportXml.php
+++ b/libraries/classes/Plugins/Export/ExportXml.php
@@ -148,51 +148,38 @@ class ExportXml extends ExportPlugin
}
/**
- * Generates output for SQL defintions of routines
+ * Generates output for SQL definitions.
*
- * @param string $db Database name
- * @param string $type Item type to be used in XML output
- * @param string $dbitype Item type used in DBI queries
+ * @param string $db Database name
+ * @param string $type Item type to be used in XML output
+ * @param string[] $names Names of items to export
+ * @psalm-param 'event'|'function'|'procedure' $type
*
* @return string XML with definitions
*/
- private function exportRoutinesDefinition($db, $type, $dbitype)
- {
- // Export routines
- $routines = $GLOBALS['dbi']->getProceduresOrFunctions($db, $dbitype);
-
- return $this->exportDefinitions($db, $type, $dbitype, $routines);
- }
-
- /**
- * Generates output for SQL defintions
- *
- * @param string $db Database name
- * @param string $type Item type to be used in XML output
- * @param string $dbitype Item type used in DBI queries
- * @param array $names Names of items to export
- *
- * @return string XML with definitions
- */
- private function exportDefinitions($db, $type, $dbitype, array $names)
+ private function exportDefinitions(string $db, string $type, array $names): string
{
$GLOBALS['crlf'] = $GLOBALS['crlf'] ?? null;
$head = '';
- if ($names) {
- foreach ($names as $name) {
- $head .= ' ' . $GLOBALS['crlf'];
+ foreach ($names as $name) {
+ $head .= ' ' . $GLOBALS['crlf'];
- // Do some formatting
- $sql = $GLOBALS['dbi']->getDefinition($db, $dbitype, $name);
- $sql = htmlspecialchars(rtrim($sql));
- $sql = str_replace("\n", "\n ", $sql);
-
- $head .= ' ' . $sql . $GLOBALS['crlf'];
- $head .= ' ' . $GLOBALS['crlf'];
+ if ($type === 'function') {
+ $definition = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $name);
+ } elseif ($type === 'procedure') {
+ $definition = $GLOBALS['dbi']->getDefinition($db, 'PROCEDURE', $name);
+ } else {
+ $definition = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $name);
}
+
+ // Do some formatting
+ $sql = htmlspecialchars(rtrim((string) $definition));
+ $sql = str_replace("\n", "\n ", $sql);
+
+ $head .= ' ' . $sql . $GLOBALS['crlf'];
+ $head .= ' ' . $GLOBALS['crlf'];
}
return $head;
@@ -331,11 +318,19 @@ class ExportXml extends ExportPlugin
}
if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
- $head .= $this->exportRoutinesDefinition($GLOBALS['db'], 'function', 'FUNCTION');
+ $head .= $this->exportDefinitions(
+ $GLOBALS['db'],
+ 'function',
+ $GLOBALS['dbi']->getProceduresOrFunctions($GLOBALS['db'], 'FUNCTION')
+ );
}
if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
- $head .= $this->exportRoutinesDefinition($GLOBALS['db'], 'procedure', 'PROCEDURE');
+ $head .= $this->exportDefinitions(
+ $GLOBALS['db'],
+ 'procedure',
+ $GLOBALS['dbi']->getProceduresOrFunctions($GLOBALS['db'], 'PROCEDURE')
+ );
}
if (isset($GLOBALS['xml_export_events']) && $GLOBALS['xml_export_events']) {
@@ -345,7 +340,7 @@ class ExportXml extends ExportPlugin
. "WHERE EVENT_SCHEMA='" . $GLOBALS['dbi']->escapeString($GLOBALS['db'])
. "'"
);
- $head .= $this->exportDefinitions($GLOBALS['db'], 'event', 'EVENT', $events);
+ $head .= $this->exportDefinitions($GLOBALS['db'], 'event', $events);
}
unset($result);
diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon
index 1149105943..aae588b43b 100644
--- a/phpstan-baseline.neon
+++ b/phpstan-baseline.neon
@@ -2545,11 +2545,6 @@ parameters:
count: 1
path: libraries/classes/DatabaseInterface.php
- -
- message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getProceduresOrFunctions\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/DatabaseInterface.php
-
-
message: "#^Method PhpMyAdmin\\\\DatabaseInterface\\:\\:getProtoInfo\\(\\) should return bool\\|int but returns int\\|string\\.$#"
count: 1
@@ -2680,11 +2675,6 @@ parameters:
count: 1
path: libraries/classes/Dbal/DbalInterface.php
- -
- message: "#^Method PhpMyAdmin\\\\Dbal\\\\DbalInterface\\:\\:getProceduresOrFunctions\\(\\) return type has no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/Dbal/DbalInterface.php
-
-
message: "#^Method PhpMyAdmin\\\\Dbal\\\\DbalInterface\\:\\:getTables\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
@@ -5505,11 +5495,6 @@ parameters:
count: 1
path: libraries/classes/Plugins/Export/ExportXml.php
- -
- message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportXml\\:\\:exportDefinitions\\(\\) has parameter \\$names with no value type specified in iterable type array\\.$#"
- count: 1
- path: libraries/classes/Plugins/Export/ExportXml.php
-
-
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportXml\\:\\:getTables\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index bc3199c1c8..63a5a40ec8 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -5734,10 +5734,12 @@
SessionCache::get('mysql_cur_user')
reset($columns)
-
+
+ $result
$this->fetchResult($sql, null, 'Field', $link)
$this->fetchResult($sql, null, null, $link)
string[]
+ string[]
$user
@@ -8663,7 +8665,7 @@
-
+
$_POST['comment']
$_POST['db_collation'] ?? ''
$_POST['new_auto_increment']
@@ -8689,12 +8691,10 @@
$event_name
$foreignTable
$foreignTable
- $function_name
$newRowFormat
$newRowFormat
$old_priv
$one_query
- $procedure_name
$this_what ?? 'data'
$trigger['create']
$view
@@ -8756,12 +8756,11 @@
$trigger['create']
$trigger['create']
-
+
$GLOBALS['auto_increment']
$arr
$event_name
$foreignTable
- $function_name
$newRowFormat
$old_priv
$old_priv
@@ -8770,7 +8769,6 @@
$old_priv
$old_priv
$one_query
- $procedure_name
$this_what
$trigger
$view
@@ -9837,16 +9835,18 @@
-
+
$code
$col_as
$db_charset
$db_collation
- $name
$table
$table
$trigger['name']
+
+ $events
+
$result[$table][1]
$result[0]['DEFAULT_CHARACTER_SET_NAME']
@@ -9860,18 +9860,16 @@
$result[$table]
-
+
$GLOBALS['tables']
$code
$col_as
$db_charset
$db_collation
- $name
$table
$trigger
-
- $sql
+
$table_alias