diff --git a/libraries/classes/Config/Form.php b/libraries/classes/Config/Form.php index e6fb04d454..12515f6c35 100644 --- a/libraries/classes/Config/Form.php +++ b/libraries/classes/Config/Form.php @@ -39,23 +39,23 @@ class Form /** * Form fields (paths), filled by {@link readFormPaths()}, indexed by field name * - * @var mixed[] + * @var string[] */ - public array $fields; + public array $fields = []; /** * Stores default values for some fields (eg. pmadb tables) * * @var mixed[] */ - public array $default; + public array $default = []; /** * Caches field types, indexed by field names * - * @var mixed[] + * @var string[] */ - private array $fieldsTypes; + private array $fieldsTypes = []; /** * A counter for the number of groups @@ -214,6 +214,7 @@ class Form // $this->fields is an array of the form: [0..n] => 'field path' // change numeric indexes to contain field names (last part of the path) + /** @var string[] $paths */ $paths = $this->fields; $this->fields = []; foreach ($paths as $path) { @@ -244,7 +245,7 @@ class Form $type = gettype($this->configFile->getDefault($path)); } - $this->fieldsTypes[$name] = $type; + $this->fieldsTypes[$name] = (string) $type; } } diff --git a/libraries/classes/RecentFavoriteTable.php b/libraries/classes/RecentFavoriteTable.php index 059b7359d4..9f375593c4 100644 --- a/libraries/classes/RecentFavoriteTable.php +++ b/libraries/classes/RecentFavoriteTable.php @@ -39,7 +39,7 @@ class RecentFavoriteTable * * @var mixed[] */ - private array $tables; + private array $tables = []; /** * RecentFavoriteTable instances. diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7699fd8687..309c685e58 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -706,22 +706,7 @@ parameters: path: libraries/classes/Config/ConfigFile.php - - message: "#^Class PhpMyAdmin\\\\Config\\\\Form has an uninitialized property \\$default\\. Give it default value or assign it in the constructor\\.$#" - count: 1 - path: libraries/classes/Config/Form.php - - - - message: "#^Class PhpMyAdmin\\\\Config\\\\Form has an uninitialized property \\$fieldsTypes\\. Give it default value or assign it in the constructor\\.$#" - count: 1 - path: libraries/classes/Config/Form.php - - - - message: "#^Empty array passed to foreach\\.$#" - count: 1 - path: libraries/classes/Config/Form.php - - - - message: "#^Method PhpMyAdmin\\\\Config\\\\Form\\:\\:getOptionType\\(\\) should return string\\|null but returns mixed\\.$#" + message: "#^Cannot cast mixed to string\\.$#" count: 1 path: libraries/classes/Config/Form.php @@ -730,21 +715,11 @@ parameters: count: 1 path: libraries/classes/Config/Form.php - - - message: "#^Parameter \\#1 \\$canonicalPath of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getDefault\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Config/Form.php - - message: "#^Parameter \\#1 \\$keys of function array_combine expects array\\, array\\, mixed\\> given\\.$#" count: 1 path: libraries/classes/Config/Form.php - - - message: "#^Parameter \\#1 \\$path of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getDbEntry\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Config/Form.php - - message: "#^Unreachable statement \\- code above always terminates\\.$#" count: 2 @@ -845,11 +820,6 @@ parameters: count: 1 path: libraries/classes/Config/FormDisplay.php - - - message: "#^Parameter \\#1 \\$optionPath of method PhpMyAdmin\\\\Config\\\\Form\\:\\:getOptionValueList\\(\\) expects string, mixed given\\.$#" - count: 2 - path: libraries/classes/Config/FormDisplay.php - - message: "#^Parameter \\#1 \\$path of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:getValue\\(\\) expects string, int\\|string\\|false given\\.$#" count: 1 @@ -867,7 +837,7 @@ parameters: - message: "#^Parameter \\#1 \\$path of static method PhpMyAdmin\\\\Config\\\\Descriptions\\:\\:get\\(\\) expects string, mixed given\\.$#" - count: 2 + count: 1 path: libraries/classes/Config/FormDisplay.php - @@ -915,26 +885,11 @@ parameters: count: 1 path: libraries/classes/Config/FormDisplay.php - - - message: "#^Parameter \\#3 \\$canonicalPath of method PhpMyAdmin\\\\Config\\\\ConfigFile\\:\\:set\\(\\) expects string\\|null, mixed given\\.$#" - count: 1 - path: libraries/classes/Config/FormDisplay.php - - message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, int\\|string\\|false given\\.$#" count: 1 path: libraries/classes/Config/FormDisplay.php - - - message: "#^Parameter \\#3 \\$subject of function str_replace expects array\\|string, mixed given\\.$#" - count: 2 - path: libraries/classes/Config/FormDisplay.php - - - - message: "#^Parameter \\#3 \\$systemPath of method PhpMyAdmin\\\\Config\\\\FormDisplay\\:\\:displayFieldInput\\(\\) expects string, mixed given\\.$#" - count: 1 - path: libraries/classes/Config/FormDisplay.php - - message: "#^Parameter \\#4 \\$workPath of method PhpMyAdmin\\\\Config\\\\FormDisplay\\:\\:displayFieldInput\\(\\) expects string, int\\|string\\|false given\\.$#" count: 1 diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 881ac28ae1..d7e2a6bb85 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -370,39 +370,22 @@ $value $value - - $path - $path - $path - $keys $keys[] - $path - $path $type $v $value - - string|null - $key $prefix $prefix $prefix - - fieldsTypes[$key] ?? null]]> - fieldsTypes[$key] ?? null]]> - - $default - $fields - $fieldsTypes $name @@ -414,21 +397,14 @@ $canonicalPath $errorList - fields[$field]]]> $ip $key - $path - $path - $path - $systemPath - $systemPath systemPaths[$systemPath]]]> $translatedPath $userPrefsDisallow ?? [] $val $validators[$path] $value - $workPath $field @@ -451,20 +427,7 @@ $_POST[$key] $_POST[$key] $_POST[$key] - systemPaths[$workPath]]]> - translatedPaths[$workPath]]]> - userprefsDisallow[$path]]]> - userprefsDisallow[$systemPath]]]> - userprefsDisallow[$systemPath]]]> - userprefsKeys[$path]]]> - userprefsKeys[$systemPath]]]> - $values[$path] - $values[$path] - $values[$systemPath] - - $values[$path] - $canonicalPath $errorList @@ -473,14 +436,7 @@ $isSetupScript $key - $path - $path - $path - $path - $paths[] - $systemPath - $toSave[$workPath] $translatedPath $userPrefsDisallow $v @@ -492,7 +448,6 @@ $valueDefault $valueDefaultJs $values[$path] - $workPath $ip diff --git a/test/classes/Config/FormTest.php b/test/classes/Config/FormTest.php index 26331dbaab..e374c9c589 100644 --- a/test/classes/Config/FormTest.php +++ b/test/classes/Config/FormTest.php @@ -124,8 +124,6 @@ class FormTest extends AbstractTestCase $this->assertEquals('preffoo/foo/bar/test', $result[0]); - $this->assertIsString($result[1]); - // needs regexp because the counter is static $this->assertMatchesRegularExpression('/^preffoo\/foo\/bar\/\:group\:end\:\d+$/', $result[1]); }