Merge pull request #18932 from kamil-tekiela/Add-type-hint-to-getStorageEngines

Add better type hint to getStorageEngines()
This commit is contained in:
Maurício Meneghini Fauth 2024-01-29 22:11:13 -03:00 committed by GitHub
commit 2866fe712e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 30 deletions

View File

@ -14635,11 +14635,6 @@ parameters:
count: 1
path: src/StorageEngine.php
-
message: "#^Cannot access offset 'Support' on mixed\\.$#"
count: 1
path: src/StorageEngine.php
-
message: "#^Cannot access offset 'desc' on mixed\\.$#"
count: 1
@ -14677,7 +14672,7 @@ parameters:
-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
count: 3
count: 2
path: src/StorageEngine.php
-
@ -14691,7 +14686,7 @@ parameters:
path: src/StorageEngine.php
-
message: "#^Method PhpMyAdmin\\\\StorageEngine\\:\\:getStorageEngines\\(\\) should return array\\<array\\> but returns mixed\\.$#"
message: "#^Method PhpMyAdmin\\\\StorageEngine\\:\\:getStorageEngines\\(\\) should return array\\<string, array\\{Engine\\: string, Comment\\: string, Support\\: string\\}\\> but returns mixed\\.$#"
count: 1
path: src/StorageEngine.php
@ -14725,16 +14720,6 @@ parameters:
count: 1
path: src/StorageEngine.php
-
message: "#^Property PhpMyAdmin\\\\StorageEngine\\:\\:\\$comment \\(string\\) does not accept mixed\\.$#"
count: 1
path: src/StorageEngine.php
-
message: "#^Property PhpMyAdmin\\\\StorageEngine\\:\\:\\$title \\(string\\) does not accept mixed\\.$#"
count: 1
path: src/StorageEngine.php
-
message: "#^Variable method call on \\$this\\(PhpMyAdmin\\\\StorageEngine\\)\\.$#"
count: 1

View File

@ -11128,11 +11128,7 @@
<code><![CDATA[$mysqlVars[$row['Variable_name']]['title']]]></code>
<code><![CDATA[$mysqlVars[$row['Variable_name']]['type']]]></code>
<code><![CDATA[$mysqlVars[$row['Variable_name']]['value']]]></code>
<code><![CDATA[$storageEngines[$engine]['Support']]]></code>
</MixedArrayAssignment>
<MixedArrayOffset>
<code><![CDATA[$engines[$details['Engine']]]]></code>
</MixedArrayOffset>
<MixedAssignment>
<code>$dataLength</code>
<code>$decodedData</code>
@ -11140,11 +11136,9 @@
<code>$indexLength</code>
<code>$mroongaData</code>
<code><![CDATA[$mysqlVars[$row['Variable_name']]]]></code>
<code><![CDATA[$this->comment]]></code>
<code><![CDATA[$this->title]]></code>
</MixedAssignment>
<MixedInferredReturnType>
<code>mixed[][]</code>
<code><![CDATA[array<string, array{Engine: string, Comment: string, Support: string}>]]></code>
<code>string</code>
</MixedInferredReturnType>
<MixedOperand>

View File

@ -67,13 +67,13 @@ class StorageEngine
public function __construct(string $engine)
{
$storageEngines = self::getStorageEngines();
if (empty($storageEngines[$engine])) {
if (! array_key_exists($engine, $storageEngines)) {
return;
}
$this->engine = $engine;
$this->title = $storageEngines[$engine]['Engine'];
$this->comment = $storageEngines[$engine]['Comment'] ?? '';
$this->comment = $storageEngines[$engine]['Comment'];
$this->support = match ($storageEngines[$engine]['Support']) {
'DEFAULT' => self::SUPPORT_DEFAULT,
'YES' => self::SUPPORT_YES,
@ -85,7 +85,7 @@ class StorageEngine
/**
* Returns array of storage engines
*
* @return mixed[][] array of storage engines
* @return array<string, array{Engine: string, Comment: string, Support: string}>
*
* @staticvar array $storage_engines storage engines
*/
@ -95,6 +95,7 @@ class StorageEngine
if ($storageEngines == null) {
$dbi = DatabaseInterface::getInstance();
/** @var array<string, array{Engine: string, Comment: string, Support: string}> $storageEngines */
$storageEngines = $dbi->fetchResult('SHOW STORAGE ENGINES', 'Engine');
if (! $dbi->isMariaDB() && $dbi->getVersion() >= 50708) {
$disabled = (string) SessionCache::get(
@ -269,9 +270,7 @@ class StorageEngine
return true;
}
$storageEngines = self::getStorageEngines();
return isset($storageEngines[$engine]);
return array_key_exists($engine, self::getStorageEngines());
}
/**