From 91aad40948e738820d8ab12055606a7fe7859a83 Mon Sep 17 00:00:00 2001 From: Kamil Tekiela Date: Mon, 7 Nov 2022 22:38:12 +0000 Subject: Refactor isEngine() method Signed-off-by: Kamil Tekiela --- libraries/classes/Table.php | 20 ++++---------------- phpstan-baseline.neon | 5 ----- psalm-baseline.xml | 3 +-- 3 files changed, 5 insertions(+), 23 deletions(-) diff --git a/libraries/classes/Table.php b/libraries/classes/Table.php index 163f80d659..a7f6e19f39 100644 --- a/libraries/classes/Table.php +++ b/libraries/classes/Table.php @@ -205,24 +205,15 @@ class Table implements Stringable /** * 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); } /** @@ -362,9 +353,6 @@ class Table implements Stringable public function getStorageEngine(): string { $tableStorageEngine = $this->getStatusInfo('ENGINE', false, true); - if ($tableStorageEngine === false) { - return ''; - } return strtoupper((string) $tableStorageEngine); } @@ -2152,7 +2140,7 @@ class Table implements Stringable $index->getChoice() !== 'SPATIAL' && $index->getChoice() !== 'FULLTEXT' && in_array($type, Index::getIndexTypes()) - && ! $this->isEngine(['TOKUDB']) + && ! $this->isEngine('TOKUDB') ) { $sqlQuery .= ' USING ' . $type; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index fd07b47ff3..810b20150f 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -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 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index fd2bafc3e5..d888ab2316 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -13640,7 +13640,7 @@ $optionsArray[$existrelForeign[$masterFieldMd5]['on_delete'] ?? ''] $optionsArray[$existrelForeign[$masterFieldMd5]['on_update'] ?? ''] - + $GLOBALS['errorUrl'] $cachedResult $cachedResult @@ -13651,7 +13651,6 @@ $constraintName $createTable $currCreateTime - $e $eachCol $foreignDb $foreignDb -- cgit v1.2.3