diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 14b1e9ccdf..5e7856115e 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -516,12 +516,6 @@ parameters: count: 4 path: src/Config/FormDisplay.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 4 - path: src/Config/FormDisplay.php - - message: '#^Call to function function_exists\(\) with ''bzcompress''\|''gzcompress''\|''gzencode'' will always evaluate to true\.$#' identifier: function.alreadyNarrowedType @@ -582,12 +576,6 @@ parameters: count: 1 path: src/Config/FormDisplay.php - - - message: '#^Parameter \#1 \$canonicalPath of method PhpMyAdmin\\Config\\ConfigFile\:\:getDefault\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Config/FormDisplay.php - - message: '#^Parameter \#1 \$optionName of method PhpMyAdmin\\Config\\Form\:\:getOptionType\(\) expects string, \(int\|string\) given\.$#' identifier: argument.type @@ -612,12 +600,6 @@ parameters: count: 1 path: src/Config/FormDisplay.php - - - message: '#^Parameter \#1 \$path of static method PhpMyAdmin\\Config\\Descriptions\:\:get\(\) expects string, mixed given\.$#' - identifier: argument.type - count: 1 - path: src/Config/FormDisplay.php - - message: '#^Parameter \#1 \$value of method PhpMyAdmin\\Config\\FormDisplay\:\:validateSelect\(\) expects bool\|string, mixed given\.$#' identifier: argument.type @@ -1251,12 +1233,6 @@ parameters: count: 1 path: src/ConfigStorage/Relation.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 1 - path: src/ConfigStorage/Relation.php - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' identifier: empty.notAllowed @@ -1752,12 +1728,6 @@ parameters: count: 1 path: src/Controllers/Database/StructureController.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 4 - path: src/Controllers/Database/StructureController.php - - message: '#^Cannot access offset ''table_limit_offset'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -2292,12 +2262,6 @@ parameters: count: 1 path: src/Controllers/Server/Databases/CreateController.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 4 - path: src/Controllers/Server/DatabasesController.php - - message: '#^Cannot access offset ''DEFAULT_COLLATION_NAME'' on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -3696,12 +3660,6 @@ parameters: count: 1 path: src/Controllers/Table/ZoomSearchController.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 2 - path: src/Controllers/Table/ZoomSearchController.php - - message: '#^Cannot access offset 0 on mixed\.$#' identifier: offsetAccess.nonOffsetAccessible @@ -8571,12 +8529,6 @@ parameters: count: 1 path: src/Plugins/Auth/AuthenticationCookie.php - - - message: '#^Only booleans are allowed in an if condition, string given\.$#' - identifier: if.condNotBoolean - count: 1 - path: src/Plugins/Auth/AuthenticationCookie.php - - message: '#^Parameter \#1 \$encryptedData of method PhpMyAdmin\\Plugins\\Auth\\AuthenticationCookie\:\:cookieDecrypt\(\) expects string, mixed given\.$#' identifier: argument.type @@ -9234,12 +9186,6 @@ parameters: count: 1 path: src/Plugins/Export/ExportXml.php - - - message: '#^Foreach overwrites \$table with its value variable\.$#' - identifier: foreach.valueOverwrite - count: 1 - path: src/Plugins/Export/ExportXml.php - - message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|null given\.$#' identifier: argument.type @@ -10095,12 +10041,6 @@ parameters: count: 2 path: src/Plugins/Schema/Dia/RelationStatsDia.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 1 - path: src/Plugins/Schema/Dia/RelationStatsDia.php - - message: '#^Loose comparison via "\!\=" is not allowed\.$#' identifier: notEqual.notAllowed @@ -10494,12 +10434,6 @@ parameters: count: 2 path: src/Plugins/Schema/Pdf/TableStatsPdf.php - - - message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#' - identifier: function.strict - count: 1 - path: src/Plugins/Schema/RelationStats.php - - message: '#^Loose comparison via "\=\=" is not allowed\.$#' identifier: equal.notAllowed diff --git a/psalm-baseline.xml b/psalm-baseline.xml index e22b742292..9c2419deb2 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -151,7 +151,7 @@ - + id]['Servers'][$i + 1]]]> @@ -163,8 +163,8 @@ id]['Servers'][$i]]]> - + @@ -238,10 +238,8 @@ - - systemPaths[$systemPath]]]> @@ -266,15 +264,14 @@ translatedPaths[$workPath]]]> - + - @@ -6114,7 +6111,6 @@ - collation)]]> diff --git a/src/Charsets/Collation.php b/src/Charsets/Collation.php index 6c58d82770..72ff8abf7f 100644 --- a/src/Charsets/Collation.php +++ b/src/Charsets/Collation.php @@ -107,7 +107,7 @@ final class Collation */ private function buildDescription(): string { - $parts = explode('_', $this->getName()); + $parts = explode('_', $this->name); $name = __('Unknown'); $variant = null; diff --git a/src/Command/TwigLintCommand.php b/src/Command/TwigLintCommand.php index a9a4f28319..c413f44145 100644 --- a/src/Command/TwigLintCommand.php +++ b/src/Command/TwigLintCommand.php @@ -170,13 +170,13 @@ class TwigLintCommand extends Command $nodeTree = $twig->parse($twig->tokenize(new Source($template, $file))); $twig->compile($nodeTree); $twig->setLoader($realLoader); - } catch (Error $e) { + } catch (Error $error) { $twig->setLoader($realLoader); return [ 'template' => $template, 'file' => $file, - 'exception' => $e, + 'exception' => $error, ]; } diff --git a/src/Config/ConfigFile.php b/src/Config/ConfigFile.php index 3d86974f52..fcce498ffe 100644 --- a/src/Config/ConfigFile.php +++ b/src/Config/ConfigFile.php @@ -471,8 +471,8 @@ class ConfigFile array_keys($this->persistKeys), array_keys($c), ); - foreach ($persistKeys as $k) { - $c[$k] = $this->getDefault($this->getCanonicalPath($k)); + foreach ($persistKeys as $persistKey) { + $c[$persistKey] = $this->getDefault($this->getCanonicalPath($persistKey)); } foreach ($this->cfgUpdateReadMapping as $mapTo => $mapFrom) { diff --git a/src/Config/FormDisplay.php b/src/Config/FormDisplay.php index d53e15c8bd..6b486089df 100644 --- a/src/Config/FormDisplay.php +++ b/src/Config/FormDisplay.php @@ -72,7 +72,7 @@ class FormDisplay * Server paths change indexes so we define maps from current server * path to the first one, indexed by work path * - * @var mixed[] + * @var string[] */ private array $systemPaths = []; @@ -172,7 +172,7 @@ class FormDisplay $paths[] = $form->name; // collect values and paths foreach ($form->fields as $path) { - $workPath = array_search($path, $this->systemPaths); + $workPath = array_search($path, $this->systemPaths, true); $values[$path] = $this->configFile->getValue($workPath); $paths[] = $path; } @@ -185,7 +185,7 @@ class FormDisplay if (is_array($errors) && $errors !== []) { $this->errors = []; foreach ($errors as $path => $errorList) { - $workPath = array_search($path, $this->systemPaths); + $workPath = array_search($path, $this->systemPaths, true); // field error if (! $workPath) { // form error, fix path @@ -262,7 +262,7 @@ class FormDisplay ]; foreach ($form->fields as $field => $path) { - $workPath = array_search($path, $this->systemPaths); + $workPath = array_search($path, $this->systemPaths, true); $translatedPath = $this->translatedPaths[$workPath]; // always true/false for user preferences display // otherwise null @@ -562,7 +562,7 @@ class FormDisplay : false; // grab POST values foreach ($form->fields as $field => $systemPath) { - $workPath = array_search($systemPath, $this->systemPaths); + $workPath = array_search($systemPath, $this->systemPaths, true); $key = $this->translatedPaths[$workPath]; $type = $form->getOptionType($field); @@ -828,13 +828,13 @@ class FormDisplay */ private function fillPostArrayParameters(array $postValues, string $key): void { - foreach ($postValues as $v) { - $v = Util::requestString($v); - if ($v === '') { + foreach ($postValues as $postValue) { + $postValue = Util::requestString($postValue); + if ($postValue === '') { continue; } - $_POST[$key][] = $v; + $_POST[$key][] = $postValue; } } diff --git a/src/Config/Forms/BaseForm.php b/src/Config/Forms/BaseForm.php index b51d9a9eb3..019ef211e2 100644 --- a/src/Config/Forms/BaseForm.php +++ b/src/Config/Forms/BaseForm.php @@ -18,12 +18,12 @@ use function is_int; abstract class BaseForm extends FormDisplay { /** - * @param ConfigFile $cf Config file instance - * @param int|null $serverId 0 if new server, validation; >= 1 if editing a server + * @param ConfigFile $configFile Config file instance + * @param int|null $serverId 0 if new server, validation; >= 1 if editing a server */ - final public function __construct(ConfigFile $cf, int|null $serverId = null) + final public function __construct(ConfigFile $configFile, int|null $serverId = null) { - parent::__construct($cf); + parent::__construct($configFile); foreach (static::getForms() as $formName => $form) { $this->registerForm($formName, $form, $serverId); diff --git a/src/Config/Forms/BaseFormList.php b/src/Config/Forms/BaseFormList.php index c9d6df3377..10faf0cc30 100644 --- a/src/Config/Forms/BaseFormList.php +++ b/src/Config/Forms/BaseFormList.php @@ -51,11 +51,11 @@ class BaseFormList return null; } - /** @param ConfigFile $cf Config file instance */ - final public function __construct(ConfigFile $cf) + /** @param ConfigFile $configFile Config file instance */ + final public function __construct(ConfigFile $configFile) { foreach (static::$all as $class) { - $this->forms[] = new $class($cf); + $this->forms[] = new $class($configFile); } } diff --git a/src/Config/PageSettings.php b/src/Config/PageSettings.php index 32b8d86d57..2b68ac7d02 100644 --- a/src/Config/PageSettings.php +++ b/src/Config/PageSettings.php @@ -83,16 +83,16 @@ class PageSettings * Process response to form * * @param FormDisplay $formDisplay Form - * @param ConfigFile $cf Configuration file + * @param ConfigFile $configFile Configuration file */ - private function processPageSettings(FormDisplay $formDisplay, ConfigFile $cf): Message|null + private function processPageSettings(FormDisplay $formDisplay, ConfigFile $configFile): Message|null { if (! $formDisplay->process(false) || $formDisplay->hasErrors()) { return null; } // save settings - $result = $this->userPreferences->save($cf->getConfigArray()); + $result = $this->userPreferences->save($configFile->getConfigArray()); if ($result === true) { // reload page $response = ResponseRenderer::getInstance(); diff --git a/src/Config/UserPreferences.php b/src/Config/UserPreferences.php index c1bea7593e..8742b52437 100644 --- a/src/Config/UserPreferences.php +++ b/src/Config/UserPreferences.php @@ -49,17 +49,17 @@ readonly class UserPreferences /** * Common initialization for user preferences modification pages * - * @param ConfigFile $cf Config file instance + * @param ConfigFile $configFile Config file instance */ - public function pageInit(ConfigFile $cf): void + public function pageInit(ConfigFile $configFile): void { $formsAllKeys = UserFormList::getFields(); - $cf->resetConfigData(); // start with a clean instance - $cf->setAllowedKeys($formsAllKeys); - $cf->setCfgUpdateReadMapping( + $configFile->resetConfigData(); // start with a clean instance + $configFile->setAllowedKeys($formsAllKeys); + $configFile->setCfgUpdateReadMapping( ['Server/hide_db' => 'Servers/1/hide_db', 'Server/only_db' => 'Servers/1/only_db'], ); - $cf->updateWithGlobalConfig($this->config->settings); + $configFile->updateWithGlobalConfig($this->config->settings); } /** diff --git a/src/Config/Validator.php b/src/Config/Validator.php index 1e06794b83..1fe01f3aae 100644 --- a/src/Config/Validator.php +++ b/src/Config/Validator.php @@ -58,17 +58,17 @@ class Validator /** * Returns validator list * - * @param ConfigFile $cf Config file instance + * @param ConfigFile $configFile Config file instance * * @return mixed[] */ - public static function getValidators(ConfigFile $cf): array + public static function getValidators(ConfigFile $configFile): array { if (self::$validators !== null) { return self::$validators; } - self::$validators = $cf->getDbEntry('_validators', []); + self::$validators = $configFile->getDbEntry('_validators', []); $config = Config::getInstance(); if ($config->isSetup()) { return self::$validators; @@ -78,7 +78,7 @@ class Validator // preferences we need original config values not overwritten // by user preferences, creating a new PhpMyAdmin\Config instance is a // better idea than hacking into its code - $uvs = $cf->getDbEntry('_userValidators', []); + $uvs = $configFile->getDbEntry('_userValidators', []); foreach ($uvs as $field => $uvList) { $uvList = (array) $uvList; foreach ($uvList as &$uv) { @@ -115,7 +115,7 @@ class Validator * cleanup in HTML document * o false - when no validators match name(s) given by $validator_id * - * @param ConfigFile $cf Config file instance + * @param ConfigFile $configFile Config file instance * @param string|string[] $validatorId ID of validator(s) to run * @param mixed[] $values Values to validate * @param bool $isPostSource tells whether $values are directly from POST request @@ -123,17 +123,17 @@ class Validator * @return mixed[]|bool */ public static function validate( - ConfigFile $cf, + ConfigFile $configFile, string|array $validatorId, array $values, bool $isPostSource, ): bool|array { // find validators $validatorId = (array) $validatorId; - $validators = self::getValidators($cf); + $validators = self::getValidators($configFile); $vids = []; foreach ($validatorId as &$vid) { - $vid = $cf->getCanonicalPath($vid); + $vid = $configFile->getCanonicalPath($vid); if (! isset($validators[$vid])) { continue; } @@ -151,7 +151,7 @@ class Validator foreach ($values as $k => $v) { $k2 = $isPostSource ? str_replace('-', '/', $k) : $k; $k2 = mb_strpos($k2, '/') - ? $cf->getCanonicalPath($k2) + ? $configFile->getCanonicalPath($k2) : $k2; $keyMap[$k2] = $k; $arguments[$k2] = $v; diff --git a/src/ConfigStorage/Relation.php b/src/ConfigStorage/Relation.php index 583fc58b1a..5d14249bc5 100644 --- a/src/ConfigStorage/Relation.php +++ b/src/ConfigStorage/Relation.php @@ -1219,7 +1219,7 @@ class Relation { $foreigner = []; foreach ($foreignKeysData as $oneKey) { - $columnIndex = array_search($column, $oneKey->indexList); + $columnIndex = array_search($column, $oneKey->indexList, true); if ($columnIndex !== false) { $foreigner['foreign_field'] = $oneKey->refIndexList[$columnIndex]; $foreigner['foreign_db'] = $oneKey->refDbName ?? Current::$database; diff --git a/src/ConfigStorage/RelationParameters.php b/src/ConfigStorage/RelationParameters.php index 41a3ff9167..78a71d2ddb 100644 --- a/src/ConfigStorage/RelationParameters.php +++ b/src/ConfigStorage/RelationParameters.php @@ -112,7 +112,7 @@ final readonly class RelationParameters try { $db = DatabaseName::from($params[self::DATABASE] ?? null); } catch (InvalidDatabaseName) { - return new self($user, null); + return new self($user); } $bookmarkFeature = null; diff --git a/src/Controllers/Database/StructureController.php b/src/Controllers/Database/StructureController.php index f06603e134..a1645b8acc 100644 --- a/src/Controllers/Database/StructureController.php +++ b/src/Controllers/Database/StructureController.php @@ -590,11 +590,11 @@ final class StructureController implements InvocableController if ($replicaInfo['status']) { $nbServReplicaDoDb = count($replicaInfo['Do_DB']); $nbServReplicaIgnoreDb = count($replicaInfo['Ignore_DB']); - $searchDoDBInTruename = array_search($table, $replicaInfo['Do_DB']); - $searchDoDBInDB = array_search(Current::$database, $replicaInfo['Do_DB']); + $searchDoDBInTruename = array_search($table, $replicaInfo['Do_DB'], true); + $searchDoDBInDB = array_search(Current::$database, $replicaInfo['Do_DB'], true); - $searchDb = array_search(Current::$database, $replicaInfo['Ignore_DB']); - $searchTable = array_search($table, $replicaInfo['Ignore_Table']); + $searchDb = array_search(Current::$database, $replicaInfo['Ignore_DB'], true); + $searchTable = array_search($table, $replicaInfo['Ignore_Table'], true); $ignored = (is_string($searchTable) && $searchTable !== '') || (is_string($searchDb) && $searchDb !== '') || $this->hasTable($replicaInfo['Wild_Ignore_Table'], $table); diff --git a/src/Controllers/Server/DatabasesController.php b/src/Controllers/Server/DatabasesController.php index 36e887eb21..75b6a45dd9 100644 --- a/src/Controllers/Server/DatabasesController.php +++ b/src/Controllers/Server/DatabasesController.php @@ -182,11 +182,11 @@ final class DatabasesController implements InvocableController ]; if ($primaryInfo['status']) { - $key = array_search($database['SCHEMA_NAME'], $primaryInfo['Ignore_DB']); + $key = array_search($database['SCHEMA_NAME'], $primaryInfo['Ignore_DB'], true); $replication['primary']['is_replicated'] = false; if ((string) $key === '') { - $key = array_search($database['SCHEMA_NAME'], $primaryInfo['Do_DB']); + $key = array_search($database['SCHEMA_NAME'], $primaryInfo['Do_DB'], true); if ((string) $key !== '' || count($primaryInfo['Do_DB']) === 0) { $replication['primary']['is_replicated'] = true; @@ -195,11 +195,11 @@ final class DatabasesController implements InvocableController } if ($replicaInfo['status']) { - $key = array_search($database['SCHEMA_NAME'], $replicaInfo['Ignore_DB']); + $key = array_search($database['SCHEMA_NAME'], $replicaInfo['Ignore_DB'], true); $replication['replica']['is_replicated'] = false; if ((string) $key === '') { - $key = array_search($database['SCHEMA_NAME'], $replicaInfo['Do_DB']); + $key = array_search($database['SCHEMA_NAME'], $replicaInfo['Do_DB'], true); if ((string) $key !== '' || count($replicaInfo['Do_DB']) === 0) { $replication['replica']['is_replicated'] = true; diff --git a/src/Controllers/Table/ChartController.php b/src/Controllers/Table/ChartController.php index c9a29a9005..5d6f61abf0 100644 --- a/src/Controllers/Table/ChartController.php +++ b/src/Controllers/Table/ChartController.php @@ -251,7 +251,7 @@ final readonly class ChartController implements InvocableController } $this->response->setRequestStatus(true); - $this->response->addJSON('message', null); + $this->response->addJSON('message'); $this->response->addJSON('chartData', json_encode($sanitizedData)); } } diff --git a/src/Controllers/Table/ZoomSearchController.php b/src/Controllers/Table/ZoomSearchController.php index ac14cc185f..fbedd56c37 100644 --- a/src/Controllers/Table/ZoomSearchController.php +++ b/src/Controllers/Table/ZoomSearchController.php @@ -260,7 +260,7 @@ final class ZoomSearchController implements InvocableController $properties[$i] = $this->getColumnProperties( $i, - (int) array_search($criteriaColumnNames[$i], $this->columnNames), + (int) array_search($criteriaColumnNames[$i], $this->columnNames, true), ); } @@ -326,7 +326,7 @@ final class ZoomSearchController implements InvocableController return; } - $key = array_search($field, $this->columnNames); + $key = array_search($field, $this->columnNames, true); $searchIndex = isset($_POST['it']) && is_numeric($_POST['it']) ? (int) $_POST['it'] : 0; diff --git a/src/Core.php b/src/Core.php index 34b5492bfd..38e7dd61a1 100644 --- a/src/Core.php +++ b/src/Core.php @@ -673,6 +673,7 @@ class Core case 'b': case 'i': case 'd': + case 'N': /* bool, integer or double */ // skip value to separator $i = strpos($data, ';', $i); @@ -691,15 +692,6 @@ class Core // remember nesting $depth++; - break; - case 'N': - /* null */ - // skip to end - $i = strpos($data, ';', $i); - if ($i === false) { - return null; - } - break; default: /* any other elements are not wanted */ diff --git a/src/Header.php b/src/Header.php index 0748a3bfad..21ce2a0de0 100644 --- a/src/Header.php +++ b/src/Header.php @@ -246,7 +246,7 @@ class Header $this->scripts->addFile('error_report.js'); } - if ($this->config->config->enable_drag_drop_import === true) { + if ($this->config->config->enable_drag_drop_import) { $this->scripts->addFile('drag_drop_import.js'); } diff --git a/src/Pdf.php b/src/Pdf.php index 0d0131fb7e..2af10f4911 100644 --- a/src/Pdf.php +++ b/src/Pdf.php @@ -120,7 +120,7 @@ class Pdf extends TCPDF /** * Improved with alias expanding. */ - public function _putpages(): void + protected function _putpages(): void { if ($this->alias !== []) { $nbPages = count($this->pages); diff --git a/src/Plugins/Auth/AuthenticationCookie.php b/src/Plugins/Auth/AuthenticationCookie.php index d6378dcf9f..a07cf32e33 100644 --- a/src/Plugins/Auth/AuthenticationCookie.php +++ b/src/Plugins/Auth/AuthenticationCookie.php @@ -291,7 +291,7 @@ class AuthenticationCookie extends AuthenticationPlugin $this->password = $password; if ($config->config->AllowArbitraryServer && isset($_REQUEST['pma_servername'])) { - if ($config->config->ArbitraryServerRegexp) { + if ($config->config->ArbitraryServerRegexp !== '') { $parts = explode(' ', $_REQUEST['pma_servername']); if (count($parts) === 2) { $tmpHost = $parts[0]; diff --git a/src/Plugins/Export/ExportSql.php b/src/Plugins/Export/ExportSql.php index 4a79f9b0af..b4dd988f8a 100644 --- a/src/Plugins/Export/ExportSql.php +++ b/src/Plugins/Export/ExportSql.php @@ -97,14 +97,14 @@ class ExportSql extends ExportPlugin private bool $createDatabase = false; private bool $dropTable = false; - private bool $procedureFunction = false; - private bool $createTable = false; + private bool $hasCreateProcedureFunction = false; + private bool $hasCreateTable = false; /** @var 'INSERT'|'UPDATE'|'REPLACE' */ private string $type = 'INSERT'; - private bool $createView = false; - private bool $createTrigger = false; + private bool $hasCreateView = false; + private bool $hasCreateTrigger = false; private bool $viewCurrentUser = false; private bool $simpleViewExport = false; private bool $ifNotExists = false; @@ -124,7 +124,7 @@ class ExportSql extends ExportPlugin private bool $utcTime = false; private bool $dropDatabase = false; private bool $viewsAsTables = false; - private bool $metadata = false; + private bool $hasMetadata = false; public static string $oldTimezone = ''; public static bool $noConstraintsComments = false; @@ -613,7 +613,7 @@ class ExportSql extends ExportPlugin */ public function exportRoutines(string $db, array $aliases = []): bool { - if (! $this->hasCreateProcedureFunction()) { + if (! $this->hasCreateProcedureFunction) { return true; } @@ -975,7 +975,7 @@ class ExportSql extends ExportPlugin */ public function exportEvents(string $db): bool { - if (! $this->hasCreateProcedureFunction()) { + if (! $this->hasCreateProcedureFunction) { return true; } @@ -1041,7 +1041,7 @@ class ExportSql extends ExportPlugin string|array $tables, array $metadataTypes, ): bool { - if (! $this->hasMetadata()) { + if (! $this->hasMetadata) { return true; } @@ -1873,7 +1873,7 @@ class ExportSql extends ExportPlugin switch ($exportMode) { case 'create_table': - if (! $this->hasCreateTable()) { + if (! $this->hasCreateTable) { return true; // User requested no table structure, so the job has been successfully completed } @@ -1885,7 +1885,7 @@ class ExportSql extends ExportPlugin $dump .= $this->getTableComments($db, $table, $aliases); break; case 'triggers': - if (! $this->hasCreateTrigger()) { + if (! $this->hasCreateTrigger) { return true; // User requested no triggers, so the job has been successfully completed } @@ -1938,7 +1938,7 @@ class ExportSql extends ExportPlugin break; case 'create_view': - if (! $this->hasCreateView()) { + if (! $this->hasCreateView) { return true; // No view to export, so the job has been successfully completed } @@ -1982,7 +1982,7 @@ class ExportSql extends ExportPlugin break; case 'stand_in': - if (! $this->hasCreateView()) { + if (! $this->hasCreateView) { return true; // No view to export, so the job has been successfully completed } @@ -2667,17 +2667,17 @@ class ExportSql extends ExportPlugin ?? $exportConfig['sql_create_database'] ?? false); $this->dropTable = (bool) ($request->getParsedBodyParam('sql_drop_table') ?? $exportConfig['sql_drop_table'] ?? false); - $this->procedureFunction = (bool) ($request->getParsedBodyParam('sql_procedure_function') + $this->hasCreateProcedureFunction = (bool) ($request->getParsedBodyParam('sql_procedure_function') ?? $exportConfig['sql_procedure_function'] ?? false); - $this->createTable = (bool) ($request->getParsedBodyParam('sql_create_table') + $this->hasCreateTable = (bool) ($request->getParsedBodyParam('sql_create_table') ?? $exportConfig['sql_create_table'] ?? false); $this->type = $this->setType($this->setStringValue( $request->getParsedBodyParam('sql_type'), $exportConfig['sql_type'] ?? null, )); - $this->createView = (bool) ($request->getParsedBodyParam('sql_create_view') + $this->hasCreateView = (bool) ($request->getParsedBodyParam('sql_create_view') ?? $exportConfig['sql_create_view'] ?? false); - $this->createTrigger = (bool) ($request->getParsedBodyParam('sql_create_trigger') + $this->hasCreateTrigger = (bool) ($request->getParsedBodyParam('sql_create_trigger') ?? $exportConfig['sql_create_trigger'] ?? false); $this->viewCurrentUser = (bool) ($request->getParsedBodyParam('sql_view_current_user') ?? $exportConfig['sql_view_current_user'] ?? false); @@ -2711,7 +2711,7 @@ class ExportSql extends ExportPlugin ?? $exportConfig['sql_drop_database'] ?? false); $this->viewsAsTables = (bool) ($request->getParsedBodyParam('sql_views_as_tables') ?? $exportConfig['sql_views_as_tables'] ?? false); - $this->metadata = (bool) ($request->getParsedBodyParam('sql_metadata') + $this->hasMetadata = (bool) ($request->getParsedBodyParam('sql_metadata') ?? $exportConfig['sql_metadata'] ?? false); } @@ -2738,16 +2738,6 @@ class ExportSql extends ExportPlugin return 'NONE'; } - private function hasCreateProcedureFunction(): bool - { - return $this->procedureFunction; - } - - private function hasCreateTable(): bool - { - return $this->createTable; - } - /** @return 'INSERT'|'UPDATE'|'REPLACE' */ private function setType(string $type): string { @@ -2758,16 +2748,6 @@ class ExportSql extends ExportPlugin return 'INSERT'; } - private function hasCreateView(): bool - { - return $this->createView; - } - - private function hasCreateTrigger(): bool - { - return $this->createTrigger; - } - public function setAutoIncrement(bool $autoIncrement): void { $this->autoIncrement = $autoIncrement; @@ -2796,9 +2776,4 @@ class ExportSql extends ExportPlugin return 50000; } - - public function hasMetadata(): bool - { - return $this->metadata; - } } diff --git a/src/Plugins/Export/ExportXml.php b/src/Plugins/Export/ExportXml.php index fd502ba4f5..69271e5596 100644 --- a/src/Plugins/Export/ExportXml.php +++ b/src/Plugins/Export/ExportXml.php @@ -37,10 +37,6 @@ use const PHP_VERSION; */ class ExportXml extends ExportPlugin { - /** - * Table name - */ - private string $table = ''; /** * Table names * @@ -183,11 +179,6 @@ class ExportXml extends ExportPlugin */ public function exportHeader(): bool { - $this->setTable(Current::$table); - - $table = $this->getTable(); - $tables = $this->getTables(); - $exportStruct = $this->exportFunctions || $this->exportProcedures || $this->exportTables @@ -239,11 +230,11 @@ class ExportXml extends ExportPlugin . '" collation="' . htmlspecialchars($dbCollation) . '" charset="' . htmlspecialchars($dbCharset) . '">' . "\n"; - if ($tables === []) { - $tables[] = $table; + if ($this->tables === []) { + $this->tables[] = Current::$table; } - foreach ($tables as $table) { + foreach ($this->tables as $table) { // Export tables and views $result = $dbi->fetchResult( 'SHOW CREATE TABLE ' . Util::backquote(Current::$database) . '.' @@ -452,34 +443,6 @@ class ExportXml extends ExportPlugin /* ~~~~~~~~~~~~~~~~~~~~ Getters and Setters ~~~~~~~~~~~~~~~~~~~~ */ - /** - * Gets the table name - */ - private function getTable(): string - { - return $this->table; - } - - /** - * Sets the table name - * - * @param string $table table name - */ - private function setTable(string $table): void - { - $this->table = $table; - } - - /** - * Gets the table names - * - * @return string[] - */ - private function getTables(): array - { - return $this->tables; - } - /** * Sets the table names * diff --git a/src/Plugins/Export/Helpers/Pdf.php b/src/Plugins/Export/Helpers/Pdf.php index 6f4ea29c74..58d801ded9 100644 --- a/src/Plugins/Export/Helpers/Pdf.php +++ b/src/Plugins/Export/Helpers/Pdf.php @@ -104,7 +104,7 @@ class Pdf extends PdfLib * @param bool $addpage if true add a page, otherwise only return * the true/false state */ - public function checkPageBreak(mixed $h = 0, mixed $y = '', mixed $addpage = true): bool + protected function checkPageBreak(mixed $h = 0, mixed $y = '', mixed $addpage = true): bool { if (TCPDF_STATIC::empty_string($y)) { $y = $this->y; diff --git a/src/Plugins/Schema/Dia/RelationStatsDia.php b/src/Plugins/Schema/Dia/RelationStatsDia.php index f27f9868df..b2f182770d 100644 --- a/src/Plugins/Schema/Dia/RelationStatsDia.php +++ b/src/Plugins/Schema/Dia/RelationStatsDia.php @@ -74,7 +74,7 @@ class RelationStatsDia */ private function getXy(TableStatsDia $table, string $column): array { - $pos = array_search($column, $table->fields); + $pos = array_search($column, $table->fields, true); // left, right, position $value = 12; if ($pos != 0) { diff --git a/src/Plugins/Schema/RelationStats.php b/src/Plugins/Schema/RelationStats.php index 868135435c..f4f596c023 100644 --- a/src/Plugins/Schema/RelationStats.php +++ b/src/Plugins/Schema/RelationStats.php @@ -102,7 +102,7 @@ abstract class RelationStats */ private function getXy(TableStats $table, string $column): array { - $pos = array_search($column, $table->fields); + $pos = array_search($column, $table->fields, true); // x_left, x_right, y return [$table->x, $table->x + $table->width, $table->y + ($pos + 1.5) * $table->heightCell]; diff --git a/src/Plugins/TwoFactor/Key.php b/src/Plugins/TwoFactor/Key.php index b0b60e23ee..b3876daa2a 100644 --- a/src/Plugins/TwoFactor/Key.php +++ b/src/Plugins/TwoFactor/Key.php @@ -96,8 +96,8 @@ class Key extends TwoFactorPlugin $this->twofactor->save(); return true; - } catch (U2FException $e) { - $this->message = $e->getMessage(); + } catch (U2FException $exception) { + $this->message = $exception->getMessage(); return false; } @@ -188,8 +188,8 @@ class Key extends TwoFactorPlugin ]; return true; - } catch (U2FException $e) { - $this->message = $e->getMessage(); + } catch (U2FException $exception) { + $this->message = $exception->getMessage(); return false; } diff --git a/src/Server/Plugin.php b/src/Server/Plugin.php index 4b93964e2a..65142cc308 100644 --- a/src/Server/Plugin.php +++ b/src/Server/Plugin.php @@ -68,19 +68,19 @@ final class Plugin public function toArray(): array { return [ - 'name' => $this->getName(), - 'version' => $this->getVersion(), - 'status' => $this->getStatus(), - 'type' => $this->getType(), - 'type_version' => $this->getTypeVersion(), - 'library' => $this->getLibrary(), - 'library_version' => $this->getLibraryVersion(), - 'author' => $this->getAuthor(), - 'description' => $this->getDescription(), - 'license' => $this->getLicense(), - 'load_option' => $this->getLoadOption(), - 'maturity' => $this->getMaturity(), - 'auth_version' => $this->getAuthVersion(), + 'name' => $this->name, + 'version' => $this->version, + 'status' => $this->status, + 'type' => $this->type, + 'type_version' => $this->typeVersion, + 'library' => $this->library, + 'library_version' => $this->libraryVersion, + 'author' => $this->author, + 'description' => $this->description, + 'license' => $this->license, + 'load_option' => $this->loadOption, + 'maturity' => $this->maturity, + 'auth_version' => $this->authVersion, ]; } diff --git a/tests/unit/CacheTest.php b/tests/unit/CacheTest.php index 0f29b868e4..149bfb9ddf 100644 --- a/tests/unit/CacheTest.php +++ b/tests/unit/CacheTest.php @@ -70,10 +70,10 @@ class CacheTest extends AbstractTestCase self::assertFalse(Cache::has($cacheKey)); Cache::set($cacheKey, $valueToCache); self::assertTrue(Cache::has($cacheKey)); - self::assertSame(Cache::get($cacheKey, null), $valueToCache); + self::assertSame(Cache::get($cacheKey), $valueToCache); Cache::remove($cacheKey); self::assertFalse(Cache::has($cacheKey)); - self::assertNull(Cache::get($cacheKey, null)); + self::assertNull(Cache::get($cacheKey)); $defaultValue = new stdClass(); self::assertSame($defaultValue, Cache::get($cacheKey, $defaultValue)); self::assertFalse(Cache::get($cacheKey, false)); diff --git a/tests/unit/Controllers/Export/Template/UpdateControllerTest.php b/tests/unit/Controllers/Export/Template/UpdateControllerTest.php index e9102e9429..6f51b9f8f6 100644 --- a/tests/unit/Controllers/Export/Template/UpdateControllerTest.php +++ b/tests/unit/Controllers/Export/Template/UpdateControllerTest.php @@ -22,9 +22,9 @@ use ReflectionProperty; #[CoversClass(UpdateController::class)] final class UpdateControllerTest extends AbstractTestCase { - protected DatabaseInterface $dbi; + private DatabaseInterface $dbi; - protected DbiDummy $dummyDbi; + private DbiDummy $dummyDbi; protected function setUp(): void { diff --git a/tests/unit/Controllers/Server/Databases/CreateControllerTest.php b/tests/unit/Controllers/Server/Databases/CreateControllerTest.php index 63138f0a3a..2f31d8f107 100644 --- a/tests/unit/Controllers/Server/Databases/CreateControllerTest.php +++ b/tests/unit/Controllers/Server/Databases/CreateControllerTest.php @@ -20,9 +20,9 @@ use function sprintf; #[CoversClass(CreateController::class)] final class CreateControllerTest extends AbstractTestCase { - protected DatabaseInterface $dbi; + private DatabaseInterface $dbi; - protected DbiDummy $dummyDbi; + private DbiDummy $dummyDbi; protected function setUp(): void { diff --git a/tests/unit/Query/GeneratorTest.php b/tests/unit/Query/GeneratorTest.php index 3ce339ab49..64731ca2d7 100644 --- a/tests/unit/Query/GeneratorTest.php +++ b/tests/unit/Query/GeneratorTest.php @@ -52,7 +52,6 @@ class GeneratorTest extends AbstractTestCase Generator::getColumns( "'mydb'", "'mytable'", - null, ), ); self::assertSame( diff --git a/tests/unit/Table/TableTest.php b/tests/unit/Table/TableTest.php index 4972717f31..27e488928a 100644 --- a/tests/unit/Table/TableTest.php +++ b/tests/unit/Table/TableTest.php @@ -1572,7 +1572,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = 'DBIdummy'; $tblStorageEngine = $dbi->getTable($targetDb, $targetTable)->getStorageEngine(); self::assertSame($expect, $tblStorageEngine); @@ -1588,7 +1588,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = 'Test comment for "table1" in \'pma_test\''; $showComment = $dbi->getTable($targetDb, $targetTable)->getComment(); self::assertSame($expect, $showComment); @@ -1604,7 +1604,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = 'utf8mb4_general_ci'; $tblCollation = $dbi->getTable($targetDb, $targetTable)->getCollation(); self::assertSame($expect, $tblCollation); @@ -1620,7 +1620,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = 'Redundant'; $rowFormat = $dbi->getTable($targetDb, $targetTable)->getRowFormat(); self::assertSame($expect, $rowFormat); @@ -1636,7 +1636,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = '5'; $autoIncrement = $dbi->getTable($targetDb, $targetTable)->getAutoIncrement(); self::assertSame($expect, $autoIncrement); @@ -1652,7 +1652,7 @@ class TableTest extends AbstractTestCase $extension = new DbiDummy(); $dbi = DatabaseInterface::getInstanceForTest($extension); $tblObject = new Table($targetTable, $targetDb, $dbi); - $tblObject->getStatusInfo(null); + $tblObject->getStatusInfo(); $expect = ['pack_keys' => 'DEFAULT', 'row_format' => 'REDUNDANT']; $createOptions = $dbi->getTable($targetDb, $targetTable)->getCreateOptions(); self::assertEquals($expect, $createOptions); diff --git a/tests/unit/WebAuthn/WebauthnLibServerTest.php b/tests/unit/WebAuthn/WebauthnLibServerTest.php index 970fb7f440..a054d6dc28 100644 --- a/tests/unit/WebAuthn/WebauthnLibServerTest.php +++ b/tests/unit/WebAuthn/WebauthnLibServerTest.php @@ -149,7 +149,7 @@ final class WebauthnLibServerTest extends TestCase 'type' => 'public-key', 'transports' => [], 'attestationType' => 'none', - 'trustPath' => ['type' => 'Webauthn\\TrustPath\\EmptyTrustPath'], + 'trustPath' => ['type' => EmptyTrustPath::class], 'aaguid' => '00000000-0000-0000-0000-000000000000', // phpcs:ignore Generic.Files.LineLength.TooLong 'credentialPublicKey' => 'pQECAyYgASFYIJV56vRrFusoDf9hm3iDmllcxxXzzKyO9WruKw4kWx7zIlgg_nq63l8IMJcIdKDJcXRh9hoz0L-nVwP1Oxil3_oNQYs', @@ -190,7 +190,7 @@ final class WebauthnLibServerTest extends TestCase 'type' => 'public-key', 'transports' => [], 'attestationType' => 'none', - 'trustPath' => ['type' => 'Webauthn\\TrustPath\\EmptyTrustPath'], + 'trustPath' => ['type' => EmptyTrustPath::class], 'aaguid' => '00000000-0000-0000-0000-000000000000', // phpcs:ignore Generic.Files.LineLength.TooLong 'credentialPublicKey' => 'pQECAyYgASFYIBw_HArIcANWNOBOxq3hH8lrHo9a17nQDxlqwybjDpHEIlggu3QUKIbALqsGuHfJI3LTKJSNmk0YCFb5oz1hjJidRMk',