Skip to content

Commit edf7b02

Browse files
Merge pull request #20023 from kamil-tekiela/Some-rector-fixes
Some rector fixes
2 parents 2f92040 + 6e21cb0 commit edf7b02

34 files changed

+113
-254
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,6 @@ parameters:
516516
count: 4
517517
path: src/Config/FormDisplay.php
518518

519-
-
520-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
521-
identifier: function.strict
522-
count: 4
523-
path: src/Config/FormDisplay.php
524-
525519
-
526520
message: '#^Call to function function_exists\(\) with ''bzcompress''\|''gzcompress''\|''gzencode'' will always evaluate to true\.$#'
527521
identifier: function.alreadyNarrowedType
@@ -582,12 +576,6 @@ parameters:
582576
count: 1
583577
path: src/Config/FormDisplay.php
584578

585-
-
586-
message: '#^Parameter \#1 \$canonicalPath of method PhpMyAdmin\\Config\\ConfigFile\:\:getDefault\(\) expects string, mixed given\.$#'
587-
identifier: argument.type
588-
count: 1
589-
path: src/Config/FormDisplay.php
590-
591579
-
592580
message: '#^Parameter \#1 \$optionName of method PhpMyAdmin\\Config\\Form\:\:getOptionType\(\) expects string, \(int\|string\) given\.$#'
593581
identifier: argument.type
@@ -612,12 +600,6 @@ parameters:
612600
count: 1
613601
path: src/Config/FormDisplay.php
614602

615-
-
616-
message: '#^Parameter \#1 \$path of static method PhpMyAdmin\\Config\\Descriptions\:\:get\(\) expects string, mixed given\.$#'
617-
identifier: argument.type
618-
count: 1
619-
path: src/Config/FormDisplay.php
620-
621603
-
622604
message: '#^Parameter \#1 \$value of method PhpMyAdmin\\Config\\FormDisplay\:\:validateSelect\(\) expects bool\|string, mixed given\.$#'
623605
identifier: argument.type
@@ -1251,12 +1233,6 @@ parameters:
12511233
count: 1
12521234
path: src/ConfigStorage/Relation.php
12531235

1254-
-
1255-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
1256-
identifier: function.strict
1257-
count: 1
1258-
path: src/ConfigStorage/Relation.php
1259-
12601236
-
12611237
message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#'
12621238
identifier: empty.notAllowed
@@ -1752,12 +1728,6 @@ parameters:
17521728
count: 1
17531729
path: src/Controllers/Database/StructureController.php
17541730

1755-
-
1756-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
1757-
identifier: function.strict
1758-
count: 4
1759-
path: src/Controllers/Database/StructureController.php
1760-
17611731
-
17621732
message: '#^Cannot access offset ''table_limit_offset'' on mixed\.$#'
17631733
identifier: offsetAccess.nonOffsetAccessible
@@ -2292,12 +2262,6 @@ parameters:
22922262
count: 1
22932263
path: src/Controllers/Server/Databases/CreateController.php
22942264

2295-
-
2296-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
2297-
identifier: function.strict
2298-
count: 4
2299-
path: src/Controllers/Server/DatabasesController.php
2300-
23012265
-
23022266
message: '#^Cannot access offset ''DEFAULT_COLLATION_NAME'' on mixed\.$#'
23032267
identifier: offsetAccess.nonOffsetAccessible
@@ -3696,12 +3660,6 @@ parameters:
36963660
count: 1
36973661
path: src/Controllers/Table/ZoomSearchController.php
36983662

3699-
-
3700-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
3701-
identifier: function.strict
3702-
count: 2
3703-
path: src/Controllers/Table/ZoomSearchController.php
3704-
37053663
-
37063664
message: '#^Cannot access offset 0 on mixed\.$#'
37073665
identifier: offsetAccess.nonOffsetAccessible
@@ -8571,12 +8529,6 @@ parameters:
85718529
count: 1
85728530
path: src/Plugins/Auth/AuthenticationCookie.php
85738531

8574-
-
8575-
message: '#^Only booleans are allowed in an if condition, string given\.$#'
8576-
identifier: if.condNotBoolean
8577-
count: 1
8578-
path: src/Plugins/Auth/AuthenticationCookie.php
8579-
85808532
-
85818533
message: '#^Parameter \#1 \$encryptedData of method PhpMyAdmin\\Plugins\\Auth\\AuthenticationCookie\:\:cookieDecrypt\(\) expects string, mixed given\.$#'
85828534
identifier: argument.type
@@ -9234,12 +9186,6 @@ parameters:
92349186
count: 1
92359187
path: src/Plugins/Export/ExportXml.php
92369188

9237-
-
9238-
message: '#^Foreach overwrites \$table with its value variable\.$#'
9239-
identifier: foreach.valueOverwrite
9240-
count: 1
9241-
path: src/Plugins/Export/ExportXml.php
9242-
92439189
-
92449190
message: '#^Parameter \#1 \$string of function htmlspecialchars expects string, string\|null given\.$#'
92459191
identifier: argument.type
@@ -10095,12 +10041,6 @@ parameters:
1009510041
count: 2
1009610042
path: src/Plugins/Schema/Dia/RelationStatsDia.php
1009710043

10098-
-
10099-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
10100-
identifier: function.strict
10101-
count: 1
10102-
path: src/Plugins/Schema/Dia/RelationStatsDia.php
10103-
1010410044
-
1010510045
message: '#^Loose comparison via "\!\=" is not allowed\.$#'
1010610046
identifier: notEqual.notAllowed
@@ -10494,12 +10434,6 @@ parameters:
1049410434
count: 2
1049510435
path: src/Plugins/Schema/Pdf/TableStatsPdf.php
1049610436

10497-
-
10498-
message: '#^Call to function array_search\(\) requires parameter \#3 to be set\.$#'
10499-
identifier: function.strict
10500-
count: 1
10501-
path: src/Plugins/Schema/RelationStats.php
10502-
1050310437
-
1050410438
message: '#^Loose comparison via "\=\=" is not allowed\.$#'
1050510439
identifier: equal.notAllowed

psalm-baseline.xml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
<code><![CDATA[$c]]></code>
152152
</MixedArgument>
153153
<MixedArgumentTypeCoercion>
154-
<code><![CDATA[$k]]></code>
154+
<code><![CDATA[$persistKey]]></code>
155155
</MixedArgumentTypeCoercion>
156156
<MixedArrayAccess>
157157
<code><![CDATA[$_SESSION[$this->id]['Servers'][$i + 1]]]></code>
@@ -163,8 +163,8 @@
163163
<MixedAssignment>
164164
<code><![CDATA[$_SESSION[$this->id]['Servers'][$i]]]></code>
165165
<code><![CDATA[$c]]></code>
166-
<code><![CDATA[$c[$k]]]></code>
167166
<code><![CDATA[$c[$mapTo]]]></code>
167+
<code><![CDATA[$c[$persistKey]]]></code>
168168
<code><![CDATA[$defaultValue]]></code>
169169
<code><![CDATA[$host]]></code>
170170
<code><![CDATA[$instanceDefaultValue]]></code>
@@ -238,10 +238,8 @@
238238
<code><![CDATA[Config::getInstance()]]></code>
239239
</DeprecatedMethod>
240240
<MixedArgument>
241-
<code><![CDATA[$canonicalPath]]></code>
242241
<code><![CDATA[$errorList]]></code>
243242
<code><![CDATA[$ip]]></code>
244-
<code><![CDATA[$this->systemPaths[$systemPath]]]></code>
245243
<code><![CDATA[$userPrefsDisallow ?? []]]></code>
246244
<code><![CDATA[$val]]></code>
247245
<code><![CDATA[$validators[$path]]]></code>
@@ -266,15 +264,14 @@
266264
<code><![CDATA[$this->translatedPaths[$workPath]]]></code>
267265
</MixedArrayTypeCoercion>
268266
<MixedAssignment>
269-
<code><![CDATA[$canonicalPath]]></code>
270267
<code><![CDATA[$errorList]]></code>
271268
<code><![CDATA[$errorList]]></code>
272269
<code><![CDATA[$ip]]></code>
273270
<code><![CDATA[$opts['errors']]]></code>
271+
<code><![CDATA[$postValue]]></code>
274272
<code><![CDATA[$proxies['-' . $i]]]></code>
275273
<code><![CDATA[$userPrefsDisallow]]></code>
276274
<code><![CDATA[$v]]></code>
277-
<code><![CDATA[$v]]></code>
278275
<code><![CDATA[$val]]></code>
279276
<code><![CDATA[$value]]></code>
280277
<code><![CDATA[$value]]></code>
@@ -6114,7 +6111,6 @@
61146111
</PossiblyNullReference>
61156112
<PossiblyUnusedReturnValue>
61166113
<code><![CDATA[bool]]></code>
6117-
<code><![CDATA[bool]]></code>
61186114
</PossiblyUnusedReturnValue>
61196115
<RiskyTruthyFalsyComparison>
61206116
<code><![CDATA[empty($column->collation)]]></code>

src/Charsets/Collation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ public function getPadAttribute(): string
107107
*/
108108
private function buildDescription(): string
109109
{
110-
$parts = explode('_', $this->getName());
110+
$parts = explode('_', $this->name);
111111

112112
$name = __('Unknown');
113113
$variant = null;

src/Command/TwigLintCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ private function validate(string $template, string $file): array
170170
$nodeTree = $twig->parse($twig->tokenize(new Source($template, $file)));
171171
$twig->compile($nodeTree);
172172
$twig->setLoader($realLoader);
173-
} catch (Error $e) {
173+
} catch (Error $error) {
174174
$twig->setLoader($realLoader);
175175

176176
return [
177177
'template' => $template,
178178
'file' => $file,
179-
'exception' => $e,
179+
'exception' => $error,
180180
];
181181
}
182182

src/Config/ConfigFile.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -471,8 +471,8 @@ public function getConfigArray(): array
471471
array_keys($this->persistKeys),
472472
array_keys($c),
473473
);
474-
foreach ($persistKeys as $k) {
475-
$c[$k] = $this->getDefault($this->getCanonicalPath($k));
474+
foreach ($persistKeys as $persistKey) {
475+
$c[$persistKey] = $this->getDefault($this->getCanonicalPath($persistKey));
476476
}
477477

478478
foreach ($this->cfgUpdateReadMapping as $mapTo => $mapFrom) {

src/Config/FormDisplay.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ class FormDisplay
7272
* Server paths change indexes so we define maps from current server
7373
* path to the first one, indexed by work path
7474
*
75-
* @var mixed[]
75+
* @var string[]
7676
*/
7777
private array $systemPaths = [];
7878

@@ -172,7 +172,7 @@ private function validate(): void
172172
$paths[] = $form->name;
173173
// collect values and paths
174174
foreach ($form->fields as $path) {
175-
$workPath = array_search($path, $this->systemPaths);
175+
$workPath = array_search($path, $this->systemPaths, true);
176176
$values[$path] = $this->configFile->getValue($workPath);
177177
$paths[] = $path;
178178
}
@@ -185,7 +185,7 @@ private function validate(): void
185185
if (is_array($errors) && $errors !== []) {
186186
$this->errors = [];
187187
foreach ($errors as $path => $errorList) {
188-
$workPath = array_search($path, $this->systemPaths);
188+
$workPath = array_search($path, $this->systemPaths, true);
189189
// field error
190190
if (! $workPath) {
191191
// form error, fix path
@@ -262,7 +262,7 @@ public function getDisplay(
262262
];
263263

264264
foreach ($form->fields as $field => $path) {
265-
$workPath = array_search($path, $this->systemPaths);
265+
$workPath = array_search($path, $this->systemPaths, true);
266266
$translatedPath = $this->translatedPaths[$workPath];
267267
// always true/false for user preferences display
268268
// otherwise null
@@ -562,7 +562,7 @@ public function save(array $forms, bool $allowPartialSave = true): bool
562562
: false;
563563
// grab POST values
564564
foreach ($form->fields as $field => $systemPath) {
565-
$workPath = array_search($systemPath, $this->systemPaths);
565+
$workPath = array_search($systemPath, $this->systemPaths, true);
566566
$key = $this->translatedPaths[$workPath];
567567
$type = $form->getOptionType($field);
568568

@@ -828,13 +828,13 @@ private function setComments(string $systemPath, array &$opts): void
828828
*/
829829
private function fillPostArrayParameters(array $postValues, string $key): void
830830
{
831-
foreach ($postValues as $v) {
832-
$v = Util::requestString($v);
833-
if ($v === '') {
831+
foreach ($postValues as $postValue) {
832+
$postValue = Util::requestString($postValue);
833+
if ($postValue === '') {
834834
continue;
835835
}
836836

837-
$_POST[$key][] = $v;
837+
$_POST[$key][] = $postValue;
838838
}
839839
}
840840

src/Config/Forms/BaseForm.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
abstract class BaseForm extends FormDisplay
1919
{
2020
/**
21-
* @param ConfigFile $cf Config file instance
22-
* @param int|null $serverId 0 if new server, validation; >= 1 if editing a server
21+
* @param ConfigFile $configFile Config file instance
22+
* @param int|null $serverId 0 if new server, validation; >= 1 if editing a server
2323
*/
24-
final public function __construct(ConfigFile $cf, int|null $serverId = null)
24+
final public function __construct(ConfigFile $configFile, int|null $serverId = null)
2525
{
26-
parent::__construct($cf);
26+
parent::__construct($configFile);
2727

2828
foreach (static::getForms() as $formName => $form) {
2929
$this->registerForm($formName, $form, $serverId);

src/Config/Forms/BaseFormList.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ public static function get(string $name): string|null
5151
return null;
5252
}
5353

54-
/** @param ConfigFile $cf Config file instance */
55-
final public function __construct(ConfigFile $cf)
54+
/** @param ConfigFile $configFile Config file instance */
55+
final public function __construct(ConfigFile $configFile)
5656
{
5757
foreach (static::$all as $class) {
58-
$this->forms[] = new $class($cf);
58+
$this->forms[] = new $class($configFile);
5959
}
6060
}
6161

src/Config/PageSettings.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,16 @@ public function init(string $formGroupName, string|null $elemId = null): void
8383
* Process response to form
8484
*
8585
* @param FormDisplay $formDisplay Form
86-
* @param ConfigFile $cf Configuration file
86+
* @param ConfigFile $configFile Configuration file
8787
*/
88-
private function processPageSettings(FormDisplay $formDisplay, ConfigFile $cf): Message|null
88+
private function processPageSettings(FormDisplay $formDisplay, ConfigFile $configFile): Message|null
8989
{
9090
if (! $formDisplay->process(false) || $formDisplay->hasErrors()) {
9191
return null;
9292
}
9393

9494
// save settings
95-
$result = $this->userPreferences->save($cf->getConfigArray());
95+
$result = $this->userPreferences->save($configFile->getConfigArray());
9696
if ($result === true) {
9797
// reload page
9898
$response = ResponseRenderer::getInstance();

src/Config/UserPreferences.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,17 @@ public function __construct(
4949
/**
5050
* Common initialization for user preferences modification pages
5151
*
52-
* @param ConfigFile $cf Config file instance
52+
* @param ConfigFile $configFile Config file instance
5353
*/
54-
public function pageInit(ConfigFile $cf): void
54+
public function pageInit(ConfigFile $configFile): void
5555
{
5656
$formsAllKeys = UserFormList::getFields();
57-
$cf->resetConfigData(); // start with a clean instance
58-
$cf->setAllowedKeys($formsAllKeys);
59-
$cf->setCfgUpdateReadMapping(
57+
$configFile->resetConfigData(); // start with a clean instance
58+
$configFile->setAllowedKeys($formsAllKeys);
59+
$configFile->setCfgUpdateReadMapping(
6060
['Server/hide_db' => 'Servers/1/hide_db', 'Server/only_db' => 'Servers/1/only_db'],
6161
);
62-
$cf->updateWithGlobalConfig($this->config->settings);
62+
$configFile->updateWithGlobalConfig($this->config->settings);
6363
}
6464

6565
/**

0 commit comments

Comments
 (0)