Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libraries/classes/DatabaseInterface.php2
-rw-r--r--libraries/classes/Dbal/DbalInterface.php2
-rw-r--r--libraries/classes/Plugins/Export/ExportXml.php69
-rw-r--r--phpstan-baseline.neon15
-rw-r--r--psalm-baseline.xml24
5 files changed, 45 insertions, 67 deletions
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 .= ' <pma:' . $type . ' name="'
- . htmlspecialchars($name) . '">' . $GLOBALS['crlf'];
+ foreach ($names as $name) {
+ $head .= ' <pma:' . $type . ' name="' . htmlspecialchars($name) . '">' . $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 .= ' </pma:' . $type . '>' . $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 .= ' </pma:' . $type . '>' . $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
@@ -2546,11 +2546,6 @@ parameters:
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
path: libraries/classes/DatabaseInterface.php
@@ -2681,11 +2676,6 @@ parameters:
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
path: libraries/classes/Dbal/DbalInterface.php
@@ -5506,11 +5496,6 @@ parameters:
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
path: libraries/classes/Plugins/Export/ExportXml.php
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 @@
<code>SessionCache::get('mysql_cur_user')</code>
<code>reset($columns)</code>
</MixedReturnStatement>
- <MixedReturnTypeCoercion occurrences="4">
+ <MixedReturnTypeCoercion occurrences="6">
+ <code>$result</code>
<code>$this-&gt;fetchResult($sql, null, 'Field', $link)</code>
<code>$this-&gt;fetchResult($sql, null, null, $link)</code>
<code>string[]</code>
+ <code>string[]</code>
</MixedReturnTypeCoercion>
<NullableReturnStatement occurrences="2">
<code>$user</code>
@@ -8663,7 +8665,7 @@
</InvalidReturnType>
</file>
<file src="libraries/classes/Operations.php">
- <MixedArgument occurrences="35">
+ <MixedArgument occurrences="33">
<code>$_POST['comment']</code>
<code>$_POST['db_collation'] ?? ''</code>
<code>$_POST['new_auto_increment']</code>
@@ -8689,12 +8691,10 @@
<code>$event_name</code>
<code>$foreignTable</code>
<code>$foreignTable</code>
- <code>$function_name</code>
<code>$newRowFormat</code>
<code>$newRowFormat</code>
<code>$old_priv</code>
<code>$one_query</code>
- <code>$procedure_name</code>
<code>$this_what ?? 'data'</code>
<code>$trigger['create']</code>
<code>$view</code>
@@ -8756,12 +8756,11 @@
<code>$trigger['create']</code>
<code>$trigger['create']</code>
</MixedArrayAccess>
- <MixedAssignment occurrences="17">
+ <MixedAssignment occurrences="15">
<code>$GLOBALS['auto_increment']</code>
<code>$arr</code>
<code>$event_name</code>
<code>$foreignTable</code>
- <code>$function_name</code>
<code>$newRowFormat</code>
<code>$old_priv</code>
<code>$old_priv</code>
@@ -8770,7 +8769,6 @@
<code>$old_priv</code>
<code>$old_priv</code>
<code>$one_query</code>
- <code>$procedure_name</code>
<code>$this_what</code>
<code>$trigger</code>
<code>$view</code>
@@ -9837,16 +9835,18 @@
</PossiblyUndefinedVariable>
</file>
<file src="libraries/classes/Plugins/Export/ExportXml.php">
- <MixedArgument occurrences="8">
+ <MixedArgument occurrences="7">
<code>$code</code>
<code>$col_as</code>
<code>$db_charset</code>
<code>$db_collation</code>
- <code>$name</code>
<code>$table</code>
<code>$table</code>
<code>$trigger['name']</code>
</MixedArgument>
+ <MixedArgumentTypeCoercion occurrences="1">
+ <code>$events</code>
+ </MixedArgumentTypeCoercion>
<MixedArrayAccess occurrences="5">
<code>$result[$table][1]</code>
<code>$result[0]['DEFAULT_CHARACTER_SET_NAME']</code>
@@ -9860,18 +9860,16 @@
<MixedArrayTypeCoercion occurrences="1">
<code>$result[$table]</code>
</MixedArrayTypeCoercion>
- <MixedAssignment occurrences="8">
+ <MixedAssignment occurrences="7">
<code>$GLOBALS['tables']</code>
<code>$code</code>
<code>$col_as</code>
<code>$db_charset</code>
<code>$db_collation</code>
- <code>$name</code>
<code>$table</code>
<code>$trigger</code>
</MixedAssignment>
- <PossiblyNullArgument occurrences="2">
- <code>$sql</code>
+ <PossiblyNullArgument occurrences="1">
<code>$table_alias</code>
</PossiblyNullArgument>
<PossiblyNullOperand occurrences="35">