Skip to content

Commit

Permalink
Refactor isEngine() method
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
  • Loading branch information
kamil-tekiela committed Nov 7, 2022
1 parent d9fcd35 commit 91aad40
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 23 deletions.
20 changes: 4 additions & 16 deletions libraries/classes/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,15 @@ public function getFullName($backquoted = false)
/**
* Checks the storage engine used to create table
*
* @param array|string $engine Checks the table engine against an
* @param string[]|string $engine Checks the table engine against an
* array of engine strings or a single string, should be uppercase
*/
public function isEngine($engine): bool
{
$engine = (array) $engine;
$tableStorageEngine = $this->getStorageEngine();

if (is_array($engine)) {
foreach ($engine as $e) {
if ($e == $tableStorageEngine) {
return true;
}
}

return false;
}

return $tableStorageEngine == $engine;
return in_array($tableStorageEngine, $engine, true);
}

/**
Expand Down Expand Up @@ -362,9 +353,6 @@ public function getStatusInfo(
public function getStorageEngine(): string
{
$tableStorageEngine = $this->getStatusInfo('ENGINE', false, true);
if ($tableStorageEngine === false) {
return '';
}

return strtoupper((string) $tableStorageEngine);
}
Expand Down Expand Up @@ -2152,7 +2140,7 @@ public function getSqlQueryForIndexCreateOrEdit($index, &$error)
$index->getChoice() !== 'SPATIAL'
&& $index->getChoice() !== 'FULLTEXT'
&& in_array($type, Index::getIndexTypes())
&& ! $this->isEngine(['TOKUDB'])
&& ! $this->isEngine('TOKUDB')
) {
$sqlQuery .= ' USING ' . $type;
}
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -8080,11 +8080,6 @@ parameters:
count: 1
path: libraries/classes/Table.php

-
message: "#^Method PhpMyAdmin\\\\Table\\:\\:isEngine\\(\\) has parameter \\$engine with no value type specified in iterable type array\\.$#"
count: 1
path: libraries/classes/Table.php

-
message: "#^Method PhpMyAdmin\\\\Table\\:\\:updateForeignKeys\\(\\) has parameter \\$destinationForeignColumn with no value type specified in iterable type array\\.$#"
count: 1
Expand Down
3 changes: 1 addition & 2 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13640,7 +13640,7 @@
<code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? '']</code>
<code>$optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? '']</code>
</MixedArrayTypeCoercion>
<MixedAssignment occurrences="48">
<MixedAssignment occurrences="47">
<code>$GLOBALS['errorUrl']</code>
<code>$cachedResult</code>
<code>$cachedResult</code>
Expand All @@ -13651,7 +13651,6 @@
<code>$constraintName</code>
<code>$createTable</code>
<code>$currCreateTime</code>
<code>$e</code>
<code>$eachCol</code>
<code>$foreignDb</code>
<code>$foreignDb</code>
Expand Down

0 comments on commit 91aad40

Please sign in to comment.