Improve type inference of exportRoutineSQL's $type param

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
This commit is contained in:
Maurício Meneghini Fauth 2022-09-11 14:40:12 -03:00
parent 1c844571f5
commit b79b9e37a0
No known key found for this signature in database
GPG Key ID: 6A16FD38AFC89CC8
2 changed files with 12 additions and 11 deletions

View File

@ -524,17 +524,17 @@ class ExportSql extends ExportPlugin
*
* @param string $db Database
* @param array $aliases Aliases of db/table/columns
* @param string $type Type of exported routine
* @param string $name Verbose name of exported routine
* @param array $routines List of routines to export
* @param string $delimiter Delimiter to use in SQL
* @psalm-param 'FUNCTION'|'PROCEDURE' $type
*
* @return string SQL query
*/
protected function exportRoutineSQL(
$db,
array $aliases,
$type,
string $type,
$name,
array $routines,
$delimiter
@ -555,13 +555,13 @@ class ExportSql extends ExportPlugin
. $delimiter . $GLOBALS['crlf'];
}
$createQuery = $this->replaceWithAliases(
$GLOBALS['dbi']->getDefinition($db, $type, $routine),
$aliases,
$db,
'',
$flag
);
if ($type === 'FUNCTION') {
$definition = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $routine);
} else {
$definition = $GLOBALS['dbi']->getDefinition($db, 'PROCEDURE', $routine);
}
$createQuery = $this->replaceWithAliases($definition, $aliases, $db, '', $flag);
if (! empty($createQuery) && $GLOBALS['cfg']['Export']['remove_definer_from_definitions']) {
// Remove definer clause from routine definitions
$parser = new Parser($createQuery);

View File

@ -9559,7 +9559,7 @@
<code>$GLOBALS['cfg']['Export']</code>
<code>$GLOBALS['cfg']['Export']</code>
</InvalidArrayOffset>
<MixedArgument occurrences="50">
<MixedArgument occurrences="51">
<code>$GLOBALS['sql_auto_increments']</code>
<code>$GLOBALS['sql_auto_increments']</code>
<code>$GLOBALS['sql_backquotes']</code>
@ -9607,6 +9607,7 @@
<code>$rel['foreign_table']</code>
<code>$routine</code>
<code>$routine</code>
<code>$routine</code>
<code>$table</code>
<code>$token-&gt;value</code>
<code>$trigger['create']</code>
@ -9702,8 +9703,8 @@
<code>Context::escape($alias)</code>
</PossiblyInvalidPropertyAssignmentValue>
<PossiblyNullArgument occurrences="5">
<code>$GLOBALS['dbi']-&gt;getDefinition($db, $type, $routine)</code>
<code>$createQuery</code>
<code>$definition</code>
<code>$tableAlias</code>
<code>$tableAlias</code>
<code>$tableAlias</code>