diff options
author | MaurĂcio Meneghini Fauth <mauricio@fauth.dev> | 2022-11-08 02:31:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-08 02:31:05 +0300 |
commit | 3c90ff3c1f3dbd5ca36e08ad4dd532e1c44f8383 (patch) | |
tree | 9780fbce64f9082c64f1a364af80a2e80f8b7da7 | |
parent | d9fcd3555b331c3668be7e8b335f426ffb681e91 (diff) | |
parent | 91aad40948e738820d8ab12055606a7fe7859a83 (diff) |
Merge pull request #17880 from kamil-tekiela/Refactor-isEngine()
Refactor isEngine() method
-rw-r--r-- | libraries/classes/Table.php | 20 | ||||
-rw-r--r-- | phpstan-baseline.neon | 5 | ||||
-rw-r--r-- | 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 @@ -8081,11 +8081,6 @@ parameters: 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 path: libraries/classes/Table.php 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 @@ <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> @@ -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> |