Refactor getColumnNames()

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2024-12-19 01:43:03 +00:00
parent c4f4a1ee9e
commit 94f70f8b68
3 changed files with 10 additions and 8 deletions

View File

@ -6958,7 +6958,7 @@ parameters:
path: src/DatabaseInterface.php
-
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:getColumnNames\(\) should return list\<string\> but returns array\<mixed\>\.$#'
message: '#^Method PhpMyAdmin\\DatabaseInterface\:\:getColumnNames\(\) should return list\<string\> but returns list\<string\|null\>\.$#'
identifier: return.type
count: 1
path: src/DatabaseInterface.php

View File

@ -4229,9 +4229,6 @@
<code><![CDATA[$row['Max_data_length']]]></code>
<code><![CDATA[$row['Rows']]]></code>
</InvalidOperand>
<LessSpecificReturnStatement>
<code><![CDATA[$this->fetchResultSimple($sql, 'Field', $connectionType)]]></code>
</LessSpecificReturnStatement>
<MixedArgument>
<code><![CDATA[$a]]></code>
<code><![CDATA[$b]]></code>
@ -4300,10 +4297,9 @@
* Visible?: string,
* Expression?: string|null
* }>]]></code>
</MixedReturnTypeCoercion>
<MoreSpecificReturnType>
<code><![CDATA[array_column($result->fetchAllAssoc(), 'Field')]]></code>
<code><![CDATA[list<string>]]></code>
</MoreSpecificReturnType>
</MixedReturnTypeCoercion>
<NullableReturnStatement>
<code><![CDATA[$user]]></code>
</NullableReturnStatement>

View File

@ -989,8 +989,14 @@ class DatabaseInterface implements DbalInterface
): array {
$sql = QueryGenerator::getColumnsSql($database, $table);
$result = $this->tryQuery($sql, $connectionType, cacheAffectedRows: false);
if ($result === false) {
return [];
}
// We only need the 'Field' column which contains the table's column names
return $this->fetchResultSimple($sql, 'Field', $connectionType);
return array_column($result->fetchAllAssoc(), 'Field');
}
/**