Merge pull request #18569 from kamil-tekiela/showCreate()

Force string as return type of showCreate()
This commit is contained in:
Maurício Meneghini Fauth 2023-07-25 08:43:43 -03:00 committed by GitHub
commit 815ec67bec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 11 additions and 53 deletions

View File

@ -444,7 +444,7 @@ class Relation
if (($source === 'both' || $source === 'foreign') && strlen($table) > 0) {
$tableObj = new Table($table, $db);
$show_create_table = $tableObj->showCreate();
if ($show_create_table) {
if ($show_create_table !== '') {
$parser = new Parser($show_create_table);
$stmt = $parser->statements[0];
$foreign['foreign_keys_data'] = [];

View File

@ -93,7 +93,7 @@ final class PartitioningController extends AbstractController
private function extractPartitionDetails(): ?array
{
$createTable = (new Table($this->table, $this->db))->showCreate();
if (! $createTable) {
if ($createTable === '') {
return null;
}

View File

@ -2584,7 +2584,7 @@ class Table implements Stringable
}
$createTable = $this->showCreate();
if (! $createTable) {
if ($createTable === '') {
return false;
}
@ -2616,12 +2616,10 @@ class Table implements Stringable
/**
* Returns the CREATE statement for this table
*
* @return mixed
*/
public function showCreate()
public function showCreate(): string
{
return $this->dbi->fetchValue(
return (string) $this->dbi->fetchValue(
'SHOW CREATE TABLE ' . Util::backquote($this->dbName) . '.'
. Util::backquote($this->name),
1

View File

@ -955,11 +955,6 @@ parameters:
count: 1
path: libraries/classes/ConfigStorage/Relation.php
-
message: "#^Parameter \\#1 \\$list of class PhpMyAdmin\\\\SqlParser\\\\Parser constructor expects PhpMyAdmin\\\\SqlParser\\\\TokensList\\|PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string\\|null, mixed given\\.$#"
count: 1
path: libraries/classes/ConfigStorage/Relation.php
-
message: "#^Parameter \\#2 \\$callback of function usort expects callable\\(string\\|null, string\\|null\\)\\: int, 'strnatcasecmp' given\\.$#"
count: 1
@ -1080,11 +1075,6 @@ parameters:
count: 1
path: libraries/classes/Controllers/Database/Structure/FavoriteTableController.php
-
message: "#^Parameter \\#1 \\$buffer of static method PhpMyAdmin\\\\Core\\:\\:mimeDefaultFunction\\(\\) expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/Database/Structure/ShowCreateController.php
-
message: "#^Cannot use array destructuring on array\\|null\\.$#"
count: 4
@ -1630,11 +1620,6 @@ parameters:
count: 1
path: libraries/classes/Controllers/Table/Structure/PartitioningController.php
-
message: "#^Parameter \\#1 \\$list of class PhpMyAdmin\\\\SqlParser\\\\Parser constructor expects PhpMyAdmin\\\\SqlParser\\\\TokensList\\|PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string\\|null, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/Table/Structure/PartitioningController.php
-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<PhpMyAdmin\\\\SqlParser\\\\Components\\\\PartitionDefinition\\>\\|null given\\.$#"
count: 1
@ -1800,11 +1785,6 @@ parameters:
count: 2
path: libraries/classes/Controllers/Transformation/WrapperController.php
-
message: "#^Parameter \\#1 \\$string of function substr expects string, mixed given\\.$#"
count: 1
path: libraries/classes/Controllers/View/CreateController.php
-
message: "#^Property PhpMyAdmin\\\\SqlParser\\\\Statements\\\\CreateStatement\\:\\:\\$body \\(array\\<PhpMyAdmin\\\\SqlParser\\\\Token\\>\\|string\\) in isset\\(\\) is not nullable\\.$#"
count: 1
@ -8405,11 +8385,6 @@ parameters:
count: 1
path: libraries/classes/Table.php
-
message: "#^Parameter \\#1 \\$list of class PhpMyAdmin\\\\SqlParser\\\\Parser constructor expects PhpMyAdmin\\\\SqlParser\\\\TokensList\\|PhpMyAdmin\\\\SqlParser\\\\UtfString\\|string\\|null, mixed given\\.$#"
count: 1
path: libraries/classes/Table.php
-
message: "#^Parameter \\#1 \\$string of function substr expects string, mixed given\\.$#"
count: 2

View File

@ -848,7 +848,7 @@
</InvalidArgument>
<InvalidReturnStatement occurrences="1"/>
<InvalidReturnType occurrences="1"/>
<MixedArgument occurrences="18">
<MixedArgument occurrences="17">
<code>$_SESSION['sql_history']</code>
<code>$_SESSION['sql_history']</code>
<code>$_SESSION['sql_history']</code>
@ -865,7 +865,6 @@
<code>$foreign_table</code>
<code>$foreign_table</code>
<code>$one_key['index_list']</code>
<code>$show_create_table</code>
<code>$tableNameReplacements[$tableName]</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="1">
@ -896,7 +895,7 @@
<code>$foreign[$key]</code>
<code>$one_key['ref_index_list'][$column_index]</code>
</MixedArrayOffset>
<MixedAssignment occurrences="25">
<MixedAssignment occurrences="24">
<code>$child_references</code>
<code>$column</code>
<code>$columns</code>
@ -918,7 +917,6 @@
<code>$key</code>
<code>$one_key</code>
<code>$relations</code>
<code>$show_create_table</code>
<code>$the_total</code>
<code>$value</code>
<code>$value</code>
@ -1756,9 +1754,6 @@
<InvalidArgument occurrences="1">
<code>$selected</code>
</InvalidArgument>
<MixedArgument occurrences="1">
<code>$object-&gt;showCreate()</code>
</MixedArgument>
</file>
<file src="libraries/classes/Controllers/Database/StructureController.php">
<InvalidScalarArgument occurrences="2">
@ -3863,12 +3858,6 @@
</PossiblyNullArgument>
</file>
<file src="libraries/classes/Controllers/Table/Structure/PartitioningController.php">
<MixedArgument occurrences="1">
<code>$createTable</code>
</MixedArgument>
<MixedAssignment occurrences="1">
<code>$createTable</code>
</MixedAssignment>
<PossiblyNullArgument occurrences="2">
<code>$stmt-&gt;partitions</code>
<code>$stmt-&gt;partitions[0]-&gt;subpartitions</code>
@ -4354,8 +4343,7 @@
<DocblockTypeContradiction occurrences="1">
<code>$view['as']</code>
</DocblockTypeContradiction>
<MixedArgument occurrences="3">
<code>$createView</code>
<MixedArgument occurrences="2">
<code>$db</code>
<code>$db</code>
</MixedArgument>
@ -4368,8 +4356,7 @@
<code>$urlParams['goto']</code>
<code>$urlParams['reload']</code>
</MixedArrayAssignment>
<MixedAssignment occurrences="7">
<code>$createView</code>
<MixedAssignment occurrences="6">
<code>$urlParams['db']</code>
<code>$view['as']</code>
<code>$view['as']</code>
@ -13491,7 +13478,7 @@
<InvalidReturnStatement occurrences="1">
<code>$tableAutoIncrement ?? ''</code>
</InvalidReturnStatement>
<MixedArgument occurrences="50">
<MixedArgument occurrences="49">
<code>$GLOBALS['sql_auto_increments']</code>
<code>$GLOBALS['sql_indexes']</code>
<code>$_POST['constraint_name'][$masterFieldMd5]</code>
@ -13502,7 +13489,6 @@
<code>$column['Extra']</code>
<code>$column['Extra']</code>
<code>$column['Extra']</code>
<code>$createTable</code>
<code>$eachCol</code>
<code>$eachCol</code>
<code>$errorUrl</code>
@ -13611,7 +13597,7 @@
<code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? '']</code>
<code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? '']</code>
</MixedArrayTypeCoercion>
<MixedAssignment occurrences="48">
<MixedAssignment occurrences="47">
<code>$altered</code>
<code>$altered</code>
<code>$cachedResult</code>
@ -13621,7 +13607,6 @@
<code>$column</code>
<code>$columns[$row['Field']]</code>
<code>$constraintName</code>
<code>$createTable</code>
<code>$currCreateTime</code>
<code>$e</code>
<code>$eachCol</code>