Specialize fetchResultSimple()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-12-19 03:06:02 +00:00
parent bab961a5a8
commit 6783294972
3 changed files with 42 additions and 183 deletions

View File

@ -312,13 +312,7 @@ parameters:
-
message: '#^Parameter \#1 \$row of method PhpMyAdmin\\Bookmarks\\BookmarkRepository\:\:createFromRow\(\) expects array\<string\>, array\<string\|null\> given\.$#'
identifier: argument.type
count: 2
path: src/Bookmarks/BookmarkRepository.php
-
message: '#^Parameter \#1 \$row of method PhpMyAdmin\\Bookmarks\\BookmarkRepository\:\:createFromRow\(\) expects array\<string\>, mixed given\.$#'
identifier: argument.type
count: 1
count: 3
path: src/Bookmarks/BookmarkRepository.php
-
@ -6982,7 +6976,7 @@ parameters:
path: src/DatabaseInterface.php
-
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:getTableIndexes\(\) should return array\<int, array\{Table\: string, Non_unique\: ''0''\|''1'', Key_name\: string, Seq_in_index\: string, Column_name\: string\|null, Collation\: ''A''\|''D''\|null, Cardinality\: string, Sub_part\: string\|null, \.\.\.\}\> but returns array\<mixed\>\.$#'
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:getTableIndexes\(\) should return array\<int, array\{Table\: string, Non_unique\: ''0''\|''1'', Key_name\: string, Seq_in_index\: string, Column_name\: string\|null, Collation\: ''A''\|''D''\|null, Cardinality\: string, Sub_part\: string\|null, \.\.\.\}\> but returns list\<array\<string\|null\>\>\.$#'
identifier: return.type
count: 1
path: src/DatabaseInterface.php
@ -10693,7 +10687,7 @@ parameters:
path: src/Navigation/Nodes/ObjectFetcher.php
-
message: '#^Method PhpMyAdmin\\Navigation\\Nodes\\ObjectFetcher\:\:getTablesAndViews\(\) should return array\<array\{name\: string, type\: string\}\> but returns array\<mixed\>\.$#'
message: '#^Method PhpMyAdmin\\Navigation\\Nodes\\ObjectFetcher\:\:getTablesAndViews\(\) should return array\<array\{name\: string, type\: string\}\> but returns list\<array\<string\|null\>\>\.$#'
identifier: return.type
count: 1
path: src/Navigation/Nodes/ObjectFetcher.php
@ -11055,12 +11049,6 @@ parameters:
count: 1
path: src/Operations.php
-
message: '#^Cannot access offset ''Table'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 4
path: src/Partitioning/Maintenance.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\DatabaseInterface\:
@ -11070,24 +11058,6 @@ parameters:
count: 4
path: src/Partitioning/Partition.php
-
message: '#^Cannot access offset ''Name'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Partitioning/Partition.php
-
message: '#^Cannot access offset ''PARTITION_NAME'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: src/Partitioning/Partition.php
-
message: '#^Cannot access offset ''SUBPARTITION_NAME'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Partitioning/Partition.php
-
message: '#^Cannot cast mixed to int\.$#'
identifier: cast.int
@ -11106,18 +11076,6 @@ parameters:
count: 1
path: src/Partitioning/Partition.php
-
message: '#^Parameter \#1 \$row of class PhpMyAdmin\\Partitioning\\Partition constructor expects array\<mixed\>, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Partitioning/Partition.php
-
message: '#^Parameter \#1 \$row of class PhpMyAdmin\\Partitioning\\SubPartition constructor expects array\<mixed\>, mixed given\.$#'
identifier: argument.type
count: 1
path: src/Partitioning/Partition.php
-
message: '#^PhpMyAdmin\\Partitioning\\Partition\:\:__construct\(\) does not call parent constructor from PhpMyAdmin\\Partitioning\\SubPartition\.$#'
identifier: constructor.missingParentCall
@ -12744,18 +12702,6 @@ parameters:
count: 3
path: src/Plugins/Export/ExportXml.php
-
message: '#^Cannot access offset ''DEFAULT_CHARACTER_SET_NAME'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Plugins/Export/ExportXml.php
-
message: '#^Cannot access offset ''DEFAULT_COLLATION_NAME'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Plugins/Export/ExportXml.php
-
message: '#^Cannot access offset ''columns'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
@ -12807,13 +12753,13 @@ parameters:
-
message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, mixed given\.$#'
identifier: argument.type
count: 3
count: 1
path: src/Plugins/Export/ExportXml.php
-
message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|null given\.$#'
identifier: argument.type
count: 2
count: 4
path: src/Plugins/Export/ExportXml.php
-
@ -15129,18 +15075,6 @@ parameters:
count: 2
path: src/Replication/Replication.php
-
message: '#^Cannot access offset ''File'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Replication/Replication.php
-
message: '#^Cannot access offset ''Position'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Replication/Replication.php
-
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
identifier: notEqual.notAllowed
@ -15148,7 +15082,7 @@ parameters:
path: src/Replication/Replication.php
-
message: '#^Method PhpMyAdmin\\Replication\\Replication\:\:replicaBinLogPrimary\(\) should return array\{File\?\: string, Position\?\: string\} but returns array\{\}\|array\{File\: mixed, Position\: mixed\}\.$#'
message: '#^Method PhpMyAdmin\\Replication\\Replication\:\:replicaBinLogPrimary\(\) should return array\{File\?\: string, Position\?\: string\} but returns array\{\}\|array\{File\: string\|null, Position\: string\|null\}\.$#'
identifier: return.type
count: 1
path: src/Replication/Replication.php
@ -15555,18 +15489,6 @@ parameters:
count: 2
path: src/Server/Privileges.php
-
message: '#^Cannot access offset ''CHARACTER_MAXIMUM_LENGTH'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 2
path: src/Server/Privileges.php
-
message: '#^Cannot access offset ''COLUMN_NAME'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 1
path: src/Server/Privileges.php
-
message: '#^Cannot access offset ''Column_priv'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
@ -17085,16 +17007,10 @@ parameters:
count: 2
path: src/Table/Table.php
-
message: '#^Cannot access offset ''Extra'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 3
path: src/Table/Table.php
-
message: '#^Cannot access offset ''Field'' on mixed\.$#'
identifier: offsetAccess.nonOffsetAccessible
count: 3
count: 2
path: src/Table/Table.php
-
@ -17194,7 +17110,7 @@ parameters:
path: src/Table/Table.php
-
message: '#^Method PhpMyAdmin\\Table\\Table\:\:getNonGeneratedColumns\(\) should return array\<string\> but returns list\<mixed\>\.$#'
message: '#^Method PhpMyAdmin\\Table\\Table\:\:getNonGeneratedColumns\(\) should return array\<string\> but returns list\<string\|null\>\.$#'
identifier: return.type
count: 1
path: src/Table/Table.php
@ -17230,7 +17146,7 @@ parameters:
path: src/Table/Table.php
-
message: '#^Parameter \#1 \$haystack of function str_contains expects string, mixed given\.$#'
message: '#^Parameter \#1 \$haystack of function str_contains expects string, string\|null given\.$#'
identifier: argument.type
count: 3
path: src/Table/Table.php
@ -17238,7 +17154,7 @@ parameters:
-
message: '#^Parameter \#1 \$identifier of static method PhpMyAdmin\\Util\:\:backquote\(\) expects string\|Stringable\|null, mixed given\.$#'
identifier: argument.type
count: 2
count: 1
path: src/Table/Table.php
-
@ -17730,6 +17646,12 @@ parameters:
count: 4
path: src/Triggers/Triggers.php
-
message: '#^PHPDoc tag @var with type array\<array\<mixed\>\> is not subtype of type list\<array\<string\|null\>\>\.$#'
identifier: varTag.type
count: 1
path: src/Triggers/Triggers.php
-
message: '#^Parameter \#1 \$haystack of function str_contains expects string, mixed given\.$#'
identifier: argument.type

View File

@ -64,13 +64,8 @@
<InvalidArgument>
<code><![CDATA[$result]]></code>
<code><![CDATA[$result]]></code>
<code><![CDATA[$row]]></code>
</InvalidArgument>
<MixedArgument>
<code><![CDATA[$row]]></code>
</MixedArgument>
<MixedAssignment>
<code><![CDATA[$row]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$this->bookmarkFeature]]></code>
</PossiblyNullArgument>
@ -6189,17 +6184,15 @@
</file>
<file src="src/Navigation/Nodes/ObjectFetcher.php">
<InvalidReturnStatement>
<code><![CDATA[$this->dbi->fetchResultSimple($query)]]></code>
<code><![CDATA[$this->dbi->fetchSingleColumn($query)]]></code>
<code><![CDATA[$this->dbi->fetchSingleColumn($query)]]></code>
</InvalidReturnStatement>
<InvalidReturnType>
<code><![CDATA[array{name:string, type:string}[]]]></code>
<code><![CDATA[string[]]]></code>
<code><![CDATA[string[]]]></code>
</InvalidReturnType>
<MixedReturnTypeCoercion>
<code><![CDATA[$this->dbi->fetchResultSimple($query)]]></code>
<code><![CDATA[array{name:string, type:string}[]]]></code>
</MixedReturnTypeCoercion>
</file>
<file src="src/Normalization.php">
<DeprecatedMethod>
@ -6443,28 +6436,12 @@
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Partitioning/Maintenance.php">
<MixedArrayAccess>
<code><![CDATA[$row['Table']]]></code>
<code><![CDATA[$row['Table']]]></code>
<code><![CDATA[$row['Table']]]></code>
<code><![CDATA[$row['Table']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$rows[$row['Table']]]]></code>
<code><![CDATA[$rows[$row['Table']]]]></code>
<code><![CDATA[$rows[$row['Table']]]]></code>
<code><![CDATA[$rows[$row['Table']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$row]]></code>
<code><![CDATA[$row]]></code>
<code><![CDATA[$row]]></code>
<code><![CDATA[$row]]></code>
<code><![CDATA[$rows[$row['Table']][]]]></code>
<code><![CDATA[$rows[$row['Table']][]]]></code>
<code><![CDATA[$rows[$row['Table']][]]]></code>
<code><![CDATA[$rows[$row['Table']][]]]></code>
</MixedAssignment>
<PossiblyNullArrayOffset>
<code><![CDATA[$rows]]></code>
<code><![CDATA[$rows]]></code>
<code><![CDATA[$rows]]></code>
<code><![CDATA[$rows]]></code>
</PossiblyNullArrayOffset>
</file>
<file src="src/Partitioning/Partition.php">
<DeprecatedMethod>
@ -6473,29 +6450,16 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<MixedArgument>
<code><![CDATA[$row]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$row['PARTITION_NAME']]]></code>
<code><![CDATA[$row['PARTITION_NAME']]]></code>
<code><![CDATA[$value['Name']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code><![CDATA[$partitionMap[$row['PARTITION_NAME']]]]></code>
<code><![CDATA[$partitionMap[$row['PARTITION_NAME']]]]></code>
<code><![CDATA[$partitionMap[$row['PARTITION_NAME']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$this->description]]></code>
<code><![CDATA[$this->expression]]></code>
<code><![CDATA[$this->method]]></code>
<code><![CDATA[$this->name]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<PossiblyInvalidArgument>
<code><![CDATA[$row]]></code>
</PossiblyInvalidArgument>
<PossiblyNullArrayOffset>
<code><![CDATA[$partitionMap]]></code>
<code><![CDATA[$partitionMap]]></code>
</PossiblyNullArrayOffset>
<PossiblyUnusedMethod>
<code><![CDATA[getDescription]]></code>
<code><![CDATA[getSubPartitions]]></code>
@ -6503,6 +6467,7 @@
</PossiblyUnusedMethod>
<RiskyTruthyFalsyComparison>
<code><![CDATA[$dbi->fetchValue('SELECT @@have_partitioning;')]]></code>
<code><![CDATA[empty($row['SUBPARTITION_NAME'])]]></code>
</RiskyTruthyFalsyComparison>
</file>
<file src="src/Partitioning/SubPartition.php">
@ -7330,20 +7295,16 @@
</InvalidArgument>
<MixedArgument>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$dbCharset]]></code>
<code><![CDATA[$dbCollation]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$result[$table][1]]]></code>
<code><![CDATA[$result[0]['DEFAULT_CHARACTER_SET_NAME']]]></code>
<code><![CDATA[$result[0]['DEFAULT_COLLATION_NAME']]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$colAs]]></code>
<code><![CDATA[$dbCharset]]></code>
<code><![CDATA[$dbCollation]]></code>
</MixedAssignment>
<PossiblyNullArgument>
<code><![CDATA[$dbCharset]]></code>
<code><![CDATA[$dbCollation]]></code>
<code><![CDATA[$record[$i]]]></code>
<code><![CDATA[$tableAlias]]></code>
</PossiblyNullArgument>
@ -8842,26 +8803,20 @@
</MixedArrayAssignment>
</file>
<file src="src/Replication/Replication.php">
<LessSpecificReturnStatement>
<code><![CDATA[$output]]></code>
</LessSpecificReturnStatement>
<MixedArgument>
<code><![CDATA[$pos['File']]]></code>
<code><![CDATA[$pos['File']]]></code>
</MixedArgument>
<MixedArrayAccess>
<code><![CDATA[$data[0]['File']]]></code>
<code><![CDATA[$data[0]['Position']]]></code>
</MixedArrayAccess>
<MixedAssignment>
<code><![CDATA[$output['File']]]></code>
<code><![CDATA[$output['Position']]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$pos['Position']]]></code>
<code><![CDATA[$pos['Position']]]></code>
</MixedOperand>
<MixedReturnTypeCoercion>
<code><![CDATA[$output]]></code>
<MoreSpecificReturnType>
<code><![CDATA[array{'File'?: string, 'Position'?: string}]]></code>
</MixedReturnTypeCoercion>
</MoreSpecificReturnType>
</file>
<file src="src/Replication/ReplicationGui.php">
<DeprecatedMethod>
@ -9054,10 +9009,6 @@
<code><![CDATA[$row['Table_priv']]]></code>
<code><![CDATA[$sqlQuery[0]]]></code>
<code><![CDATA[$sqlQuery[0]]]></code>
<code><![CDATA[$val['CHARACTER_MAXIMUM_LENGTH']]]></code>
<code><![CDATA[$val['CHARACTER_MAXIMUM_LENGTH']]]></code>
<code><![CDATA[$val['COLUMN_NAME']]]></code>
<code><![CDATA[$val['COLUMN_NAME']]]></code>
</MixedArrayAccess>
<MixedArrayAssignment>
<code><![CDATA[$dbRights[$row['User']][$row['Host']]]]></code>
@ -9073,7 +9024,6 @@
<code><![CDATA[$foundRows[]]]></code>
<code><![CDATA[$grantValue]]></code>
<code><![CDATA[$host]]></code>
<code><![CDATA[$hostnameLength]]></code>
<code><![CDATA[$name]]></code>
<code><![CDATA[$name]]></code>
<code><![CDATA[$name]]></code>
@ -9088,8 +9038,6 @@
<code><![CDATA[$sqlQuery]]></code>
<code><![CDATA[$sqlQuery]]></code>
<code><![CDATA[$user]]></code>
<code><![CDATA[$usernameLength]]></code>
<code><![CDATA[$val]]></code>
</MixedAssignment>
<MixedOperand>
<code><![CDATA[$origValue]]></code>
@ -9832,6 +9780,7 @@
<code><![CDATA[DatabaseInterface::getInstance()]]></code>
</DeprecatedMethod>
<InvalidReturnStatement>
<code><![CDATA[$ret]]></code>
<code><![CDATA[$tableAutoIncrement ?? '']]></code>
<code><![CDATA[$this->getStatusInfo('TABLE_COLLATION') ?? '']]></code>
<code><![CDATA[$this->getStatusInfo('TABLE_COMMENT') ?? '']]></code>
@ -9840,11 +9789,10 @@
<code><![CDATA[string]]></code>
<code><![CDATA[string]]></code>
<code><![CDATA[string]]></code>
<code><![CDATA[string[]]]></code>
</InvalidReturnType>
<MixedArgument>
<code><![CDATA[$_POST['constraint_name'][$masterFieldMd5]]]></code>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$fields[$column]['expr']]]></code>
<code><![CDATA[$index]]></code>
<code><![CDATA[$index[0]]]></code>
@ -9852,7 +9800,6 @@
<code><![CDATA[$row['Type']]]></code>
<code><![CDATA[$this->uiprefs[$property->value]]]></code>
<code><![CDATA[$this->uiprefs[$property->value]]]></code>
<code><![CDATA[$value]]></code>
</MixedArgument>
<MixedArgumentTypeCoercion>
<code><![CDATA[$indexed]]></code>
@ -9860,9 +9807,6 @@
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code><![CDATA[$_SESSION['tmpval']['table_uiprefs'][$serverId][$this->dbName][$this->name]]]></code>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$column['Field']]]></code>
<code><![CDATA[$existrel[$masterField]['foreign_db']]]></code>
<code><![CDATA[$existrel[$masterField]['foreign_field']]]></code>
<code><![CDATA[$existrel[$masterField]['foreign_table']]]></code>
@ -9886,12 +9830,9 @@
<code><![CDATA[$optionsArray[$_POST['on_update'][$masterFieldMd5]]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code><![CDATA[$column]]></code>
<code><![CDATA[$columns[$row['Field']]]]></code>
<code><![CDATA[$index]]></code>
<code><![CDATA[$ret[]]]></code>
<code><![CDATA[$row]]></code>
<code><![CDATA[$value]]></code>
</MixedAssignment>
<MixedInferredReturnType>
<code><![CDATA[mixed[]]]></code>
@ -9904,9 +9845,7 @@
</MixedReturnStatement>
<MixedReturnTypeCoercion>
<code><![CDATA[$columns]]></code>
<code><![CDATA[$ret]]></code>
<code><![CDATA[array<string, string>]]></code>
<code><![CDATA[string[]]]></code>
</MixedReturnTypeCoercion>
<PossiblyInvalidArgument>
<code><![CDATA[$_POST['constraint_name'][$masterFieldMd5]]]></code>
@ -9920,6 +9859,8 @@
<code><![CDATA[$_POST['on_update'][$masterFieldMd5]]]></code>
</PossiblyInvalidArrayOffset>
<PossiblyNullArgument>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$column['Extra']]]></code>
<code><![CDATA[$existrelForeign[$masterFieldMd5]->refDbName]]></code>
<code><![CDATA[$existrelForeign[$masterFieldMd5]->refTableName]]></code>
</PossiblyNullArgument>

View File

@ -1352,7 +1352,7 @@ class DatabaseInterface implements DbalInterface
return $resultRows;
}
/** @return array<mixed> */
/** @return list<array<string|null>> */
public function fetchResultSimple(
string $query,
ConnectionType $connectionType = ConnectionType::User,
@ -1363,10 +1363,6 @@ class DatabaseInterface implements DbalInterface
return [];
}
if ($result->numFields() === 1) {
return $result->fetchAllColumn();
}
return $result->fetchAllAssoc();
}