Skip to content

Commit 8e4443b

Browse files
Applying suggestions from static analysis tools (#19013)
* Drop array keys from lists Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Import UrlTest When it doesn't exist in Prod, the code will still work the same. Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Drop redundant return []; Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix object access checks Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use strict comparison Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Int keys should be specified as integers Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use empty string check instead of strlen Potential null deprecations are replaced with loose condition. Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use stripos instead of *substr Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify substr's 3rd param Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove unnecessary defaults Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Replace isZeroBasedArray with array_is_list Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify texEscape() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Simplify exportZeroBasedArray() Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Replace for loop with array_diff Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Replace for with foreach Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove nullable param in backquoteCompat Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use null-coalescing operator Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Inline $result variable Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Turn $event into a constant Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Move selectDb outside the loop Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Fix code style order of operation Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove unnecessary isset argument Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Remove line break Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> * Use foreach instead of for Signed-off-by: Kamil Tekiela <tekiela246@gmail.com> --------- Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
1 parent e68e814 commit 8e4443b

77 files changed

Lines changed: 256 additions & 425 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpstan-baseline.neon

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,11 +1335,6 @@ parameters:
13351335
count: 2
13361336
path: src/ConfigStorage/Relation.php
13371337

1338-
-
1339-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
1340-
count: 1
1341-
path: src/ConfigStorage/Relation.php
1342-
13431338
-
13441339
message: "#^Parameter \\#1 \\$type of method PhpMyAdmin\\\\Types\\:\\:getTypeClass\\(\\) expects string, mixed given\\.$#"
13451340
count: 1
@@ -1375,11 +1370,6 @@ parameters:
13751370
count: 1
13761371
path: src/ConfigStorage/UserGroups.php
13771372

1378-
-
1379-
message: "#^Only booleans are allowed in &&, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given on the left side\\.$#"
1380-
count: 1
1381-
path: src/ConfigStorage/UserGroups.php
1382-
13831373
-
13841374
message: "#^Only booleans are allowed in &&, int\\|string given on the right side\\.$#"
13851375
count: 1
@@ -3030,11 +3020,6 @@ parameters:
30303020
count: 1
30313021
path: src/Controllers/Operations/TableController.php
30323022

3033-
-
3034-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
3035-
count: 1
3036-
path: src/Controllers/Operations/TableController.php
3037-
30383023
-
30393024
message: "#^Parameter \\#1 \\$urlParams of method PhpMyAdmin\\\\Operations\\:\\:getForeignersForReferentialIntegrityCheck\\(\\) expects array, mixed given\\.$#"
30403025
count: 1
@@ -9610,11 +9595,6 @@ parameters:
96109595
count: 1
96119596
path: src/Normalization.php
96129597

9613-
-
9614-
message: "#^Only booleans are allowed in &&, int given on the left side\\.$#"
9615-
count: 2
9616-
path: src/Normalization.php
9617-
96189598
-
96199599
message: "#^Only booleans are allowed in a negated boolean, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given\\.$#"
96209600
count: 3
@@ -10197,7 +10177,7 @@ parameters:
1019710177

1019810178
-
1019910179
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
10200-
count: 2
10180+
count: 1
1020110181
path: src/Plugins/Auth/AuthenticationCookie.php
1020210182

1020310183
-
@@ -14080,11 +14060,6 @@ parameters:
1408014060
count: 3
1408114061
path: src/Table/Search.php
1408214062

14083-
-
14084-
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
14085-
count: 1
14086-
path: src/Table/Search.php
14087-
1408814063
-
1408914064
message: "#^Parameter \\#1 \\$string of function trim expects string, mixed given\\.$#"
1409014065
count: 3
@@ -14650,11 +14625,6 @@ parameters:
1465014625
count: 1
1465114626
path: src/Transformations.php
1465214627

14653-
-
14654-
message: "#^Parameter \\#1 \\$string of function strlen expects string, string\\|null given\\.$#"
14655-
count: 1
14656-
path: src/Transformations.php
14657-
1465814628
-
1465914629
message: "#^Argument of an invalid type mixed supplied for foreach, only iterables are supported\\.$#"
1466014630
count: 1
@@ -14990,11 +14960,6 @@ parameters:
1499014960
count: 1
1499114961
path: src/Util.php
1499214962

14993-
-
14994-
message: "#^Only booleans are allowed in a negated boolean, bool\\|null given\\.$#"
14995-
count: 1
14996-
path: src/Util.php
14997-
1499814963
-
1499914964
message: "#^Only booleans are allowed in a negated boolean, int\\<0, 2\\> given\\.$#"
1500014965
count: 1

psalm-baseline.xml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -721,7 +721,6 @@
721721
<code><![CDATA[$foreignField]]></code>
722722
<code><![CDATA[$foreignTable]]></code>
723723
<code><![CDATA[$foreignTable]]></code>
724-
<code><![CDATA[$foreign[$field]]]></code>
725724
<code><![CDATA[$oneKey['index_list']]]></code>
726725
</MixedArgument>
727726
<MixedArgumentTypeCoercion>
@@ -5162,6 +5161,7 @@
51625161
<code><![CDATA[$_SESSION['tmpval']['query']]]></code>
51635162
<code><![CDATA[$_SESSION['tmpval']['query']]]></code>
51645163
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]]]></code>
5164+
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]]]></code>
51655165
<code><![CDATA[$_SESSION['tmpval']['query'][$sqlMd5]['max_rows']]]></code>
51665166
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
51675167
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
@@ -5720,7 +5720,7 @@
57205720
<code><![CDATA[Config::getInstance()]]></code>
57215721
</DeprecatedMethod>
57225722
<FalsableReturnStatement>
5723-
<code><![CDATA[$this->detectCompression()]]></code>
5723+
<code><![CDATA[$this->compression ?? $this->detectCompression()]]></code>
57245724
</FalsableReturnStatement>
57255725
<InvalidArrayOffset>
57265726
<code><![CDATA[$_FILES['fields_upload']['name']['multi_edit']]]></code>
@@ -7515,7 +7515,6 @@
75157515
<PossiblyInvalidArgument>
75167516
<code><![CDATA[$_POST[$config->settings['CaptchaResponseParam']]]]></code>
75177517
<code><![CDATA[$_POST['pma_username']]]></code>
7518-
<code><![CDATA[$_POST['pma_username']]]></code>
75197518
<code><![CDATA[$_REQUEST['pma_servername']]]></code>
75207519
<code><![CDATA[$_REQUEST['pma_servername']]]></code>
75217520
<code><![CDATA[$password]]></code>
@@ -7797,11 +7796,9 @@
77977796
<code><![CDATA[$GLOBALS['latex_caption']]]></code>
77987797
<code><![CDATA[$GLOBALS['latex_caption']]]></code>
77997798
<code><![CDATA[$GLOBALS['latex_columns']]]></code>
7800-
<code><![CDATA[$escape[$k]]]></code>
78017799
</InvalidArrayOffset>
78027800
<MixedArgument>
78037801
<code><![CDATA[$columnsAlias[$i]]]></code>
7804-
<code><![CDATA[$escape[$k]]]></code>
78057802
<code><![CDATA[$mimeMap[$fieldName]['mimetype']]]></code>
78067803
</MixedArgument>
78077804
<MixedArrayAccess>
@@ -7816,7 +7813,6 @@
78167813
<MixedOperand>
78177814
<code><![CDATA[$colAs]]></code>
78187815
<code><![CDATA[$comments[$fieldName]]]></code>
7819-
<code><![CDATA[$escape[$k]]]></code>
78207816
<code><![CDATA[$type]]></code>
78217817
</MixedOperand>
78227818
<PossiblyFalseReference>
@@ -10998,7 +10994,6 @@
1099810994
<code><![CDATA[$criteriaValues]]></code>
1099910995
<code><![CDATA[$criteriaValues]]></code>
1100010996
<code><![CDATA[$criteriaValues]]></code>
11001-
<code><![CDATA[$criteriaValues]]></code>
1100210997
<code><![CDATA[$criteriaValues[$e]]]></code>
1100310998
<code><![CDATA[$criteriaValues[0]]]></code>
1100410999
<code><![CDATA[$operator]]></code>
@@ -11017,6 +11012,7 @@
1101711012
<code><![CDATA[$criteriaValues]]></code>
1101811013
<code><![CDATA[$criteriaValues]]></code>
1101911014
<code><![CDATA[$criteriaValues]]></code>
11015+
<code><![CDATA[$criteriaValues]]></code>
1102011016
<code><![CDATA[$needsQuoting ? $this->dbi->quoteString($criteriaValues) : $criteriaValues]]></code>
1102111017
<code><![CDATA[$values[0] ?? '']]></code>
1102211018
<code><![CDATA[$values[1] ?? '']]></code>
@@ -11524,9 +11520,6 @@
1152411520
<MixedReturnStatement>
1152511521
<code><![CDATA[$stack]]></code>
1152611522
</MixedReturnStatement>
11527-
<PossiblyNullArgument>
11528-
<code><![CDATA[$row['comment']]]></code>
11529-
</PossiblyNullArgument>
1153011523
<PossiblyUnusedReturnValue>
1153111524
<code><![CDATA[bool]]></code>
1153211525
</PossiblyUnusedReturnValue>
@@ -11707,9 +11700,6 @@
1170711700
</MixedArgument>
1170811701
</file>
1170911702
<file src="src/Util.php">
11710-
<ArgumentTypeCoercion>
11711-
<code><![CDATA[$separator]]></code>
11712-
</ArgumentTypeCoercion>
1171311703
<DeprecatedMethod>
1171411704
<code><![CDATA[Config::getInstance()]]></code>
1171511705
<code><![CDATA[Config::getInstance()]]></code>

src/Advisory/Advisor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class Advisor
3535
private array $variables = [];
3636

3737
/** @var mixed[] */
38-
private array $globals = [];
38+
private array $globals;
3939

4040
/**
4141
* @var array<int, array<string, string>>

src/Bookmarks/Bookmark.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ public function applyVariables(array $variables): string
141141

142142
$query = str_replace('[VARIABLE' . $i . ']', $var, $query);
143143
// backward compatibility
144-
if ($i != 1) {
144+
if ($i !== 1) {
145145
continue;
146146
}
147147

src/Charsets.php

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -179,13 +179,9 @@ public static function getServerCharset(DatabaseInterface $dbi, bool $disableIs)
179179
return self::$charsets['utf8'];
180180
}
181181

182-
if (self::$serverCharset === null) {// Fallback in case nothing is found
183-
return Charset::fromServer(
184-
['Charset' => __('Unknown'), 'Description' => __('Unknown')],
185-
);
186-
}
187-
188-
return self::$serverCharset;
182+
return self::$serverCharset ?? Charset::fromServer(
183+
['Charset' => __('Unknown'), 'Description' => __('Unknown')],
184+
);
189185
}
190186

191187
/**

src/Config.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
use function str_ends_with;
5757
use function stripos;
5858
use function strtolower;
59-
use function substr;
6059
use function sys_get_temp_dir;
6160
use function time;
6261
use function trim;
@@ -770,7 +769,7 @@ public function isHttps(): bool
770769
$isHttps = true;
771770
} elseif (strtolower(Core::getEnv('HTTPS')) === 'on') {
772771
$isHttps = true;
773-
} elseif (strtolower(substr(Core::getEnv('REQUEST_URI'), 0, 6)) === 'https:') {
772+
} elseif (stripos(Core::getEnv('REQUEST_URI'), 'https:') === 0) {
774773
$isHttps = true;
775774
} elseif (strtolower(Core::getEnv('HTTP_HTTPS_FROM_LB')) === 'on') {
776775
// A10 Networks load balancer
@@ -901,7 +900,7 @@ public function setCookie(
901900
if ($validity === null) {
902901
/* Valid for one month */
903902
$validity = time() + 2592000;
904-
} elseif ($validity == 0) {
903+
} elseif ($validity === 0) {
905904
/* Valid for session */
906905
$validity = 0;
907906
} else {

src/Config/ConfigFile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -604,13 +604,13 @@ public function getAllowedValues(): array
604604
],
605605
'InitialSlidersState' => ['open' => __('Open'), 'closed' => __('Closed'), 'disabled' => __('Disabled')],
606606
'FirstDayOfCalendar' => [
607-
'1' => _pgettext('Week day name', 'Monday'),
608-
'2' => _pgettext('Week day name', 'Tuesday'),
609-
'3' => _pgettext('Week day name', 'Wednesday'),
610-
'4' => _pgettext('Week day name', 'Thursday'),
611-
'5' => _pgettext('Week day name', 'Friday'),
612-
'6' => _pgettext('Week day name', 'Saturday'),
613-
'7' => _pgettext('Week day name', 'Sunday'),
607+
1 => _pgettext('Week day name', 'Monday'),
608+
2 => _pgettext('Week day name', 'Tuesday'),
609+
3 => _pgettext('Week day name', 'Wednesday'),
610+
4 => _pgettext('Week day name', 'Thursday'),
611+
5 => _pgettext('Week day name', 'Friday'),
612+
6 => _pgettext('Week day name', 'Saturday'),
613+
7 => _pgettext('Week day name', 'Sunday'),
614614
],
615615
'SendErrorReports' => [
616616
'ask' => __('Ask before sending error reports'),

0 commit comments

Comments
 (0)