Skip to content

Commit 2386830

Browse files
committed
Fix PHP 7.2 code and psalm/phpstan baselines.
1 parent ce3a175 commit 2386830

File tree

3 files changed

+14
-38
lines changed

3 files changed

+14
-38
lines changed

phpstan-baseline.neon

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ parameters:
126126
path: src/Components/Expression.php
127127

128128
-
129-
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<string\\>\\|string given\\.$#"
129+
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<string\\>\\|string given\\.$#"
130130
count: 1
131131
path: src/Components/Expression.php
132132

@@ -316,7 +316,7 @@ parameters:
316316
path: src/Components/OptionsArray.php
317317

318318
-
319-
message: "#^Parameter \\#2 \\$str2 of function strcasecmp expects string, mixed given\\.$#"
319+
message: "#^Parameter \\#2 \\$string2 of function strcasecmp expects string, mixed given\\.$#"
320320
count: 2
321321
path: src/Components/OptionsArray.php
322322

@@ -411,7 +411,7 @@ parameters:
411411
path: src/Components/Reference.php
412412

413413
-
414-
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<string\\>\\|string given\\.$#"
414+
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<string\\>\\|string given\\.$#"
415415
count: 1
416416
path: src/Components/Reference.php
417417

@@ -801,12 +801,7 @@ parameters:
801801
path: src/Tools/ContextGenerator.php
802802

803803
-
804-
message: "#^Offset 'keywords' on array\\{name\\: string, class\\: string, link\\: string, keywords\\: array\\<int, array\\<int, array\\<int, string\\>\\>\\>\\} in isset\\(\\) always exists and is not nullable\\.$#"
805-
count: 1
806-
path: src/Tools/ContextGenerator.php
807-
808-
-
809-
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
804+
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
810805
count: 1
811806
path: src/Tools/ContextGenerator.php
812807

@@ -821,12 +816,12 @@ parameters:
821816
path: src/Tools/TestGenerator.php
822817

823818
-
824-
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, string\\|null given\\.$#"
819+
message: "#^Parameter \\#1 \\$directory of function mkdir expects string, string\\|null given\\.$#"
825820
count: 1
826821
path: src/Tools/TestGenerator.php
827822

828823
-
829-
message: "#^Parameter \\#1 \\$pathname of function mkdir expects string, string\\|null given\\.$#"
824+
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, string\\|null given\\.$#"
830825
count: 1
831826
path: src/Tools/TestGenerator.php
832827

@@ -911,7 +906,7 @@ parameters:
911906
path: src/Utils/Formatter.php
912907

913908
-
914-
message: "#^Parameter \\#1 \\$input of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
909+
message: "#^Parameter \\#1 \\$string of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
915910
count: 1
916911
path: src/Utils/Formatter.php
917912

@@ -966,7 +961,7 @@ parameters:
966961
path: src/Utils/Routine.php
967962

968963
-
969-
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<int\\<0, max\\>, mixed\\>\\|string given\\.$#"
964+
message: "#^Parameter \\#2 \\$array of function implode expects array\\|null, array\\<int\\<0, max\\>, mixed\\>\\|string given\\.$#"
970965
count: 1
971966
path: src/Utils/Routine.php
972967

@@ -996,7 +991,7 @@ parameters:
996991
path: src/Utils/Tokens.php
997992

998993
-
999-
message: "#^Parameter \\#1 \\$str1 of function strcasecmp expects string, int\\|string given\\.$#"
994+
message: "#^Parameter \\#1 \\$string1 of function strcasecmp expects string, int\\|string given\\.$#"
1000995
count: 1
1001996
path: src/Utils/Tokens.php
1002997

@@ -1130,16 +1125,6 @@ parameters:
11301125
count: 1
11311126
path: tests/Parser/WithStatementTest.php
11321127

1133-
-
1134-
message: "#^Cannot access offset int\\<0, max\\> on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
1135-
count: 1
1136-
path: tests/Utils/BufferedQueryTest.php
1137-
1138-
-
1139-
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<int, string\\>\\|false given\\.$#"
1140-
count: 1
1141-
path: tests/Utils/BufferedQueryTest.php
1142-
11431128
-
11441129
message: "#^Parameter \\#1 \\$statement of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Misc\\:\\:getAliases\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement, PhpMyAdmin\\\\SqlParser\\\\Statement\\|null given\\.$#"
11451130
count: 1

psalm-baseline.xml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -656,9 +656,6 @@
656656
<file src="src/Contexts/ContextMySql80300.php">
657657
<PropertyTypeCoercion occurrences="1"/>
658658
</file>
659-
<file src="src/Contexts/ContextMySql80400.php">
660-
<PropertyTypeCoercion occurrences="1"/>
661-
</file>
662659
<file src="src/Lexer.php">
663660
<LoopInvalidation occurrences="3">
664661
<code>$this-&gt;last</code>
@@ -1163,15 +1160,6 @@
11631160
<code>is_array($list)</code>
11641161
</RedundantConditionGivenDocblockType>
11651162
</file>
1166-
<file src="src/Tools/ContextGenerator.php">
1167-
<PossiblyNullArgument occurrences="1">
1168-
<code>$options['keywords']</code>
1169-
</PossiblyNullArgument>
1170-
<RedundantCondition occurrences="2">
1171-
<code>++$i !== $count</code>
1172-
<code>++$i !== $count</code>
1173-
</RedundantCondition>
1174-
</file>
11751163
<file src="src/Tools/CustomJsonSerializer.php">
11761164
<MixedAssignment occurrences="2">
11771165
<code>$data[$property]</code>

src/Tools/ContextGenerator.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,10 @@ public static function sortWords(array &$arr)
170170
public static function readWords(array $files)
171171
{
172172
/** @psalm-var list<string> $words */
173-
$words = array_merge(...array_map('\\file', $files));
173+
$words = [];
174+
foreach (array_map('file', $files) as $wordsByFile) {
175+
$words = array_merge($words, $wordsByFile);
176+
}
174177

175178
/** @var array<string, int> $types */
176179
$types = [];
@@ -305,7 +308,7 @@ public static function formatName($name)
305308
$versionString = '0' . $versionString;
306309
}
307310

308-
$version = array_map('\\intval', str_split($versionString, 2));
311+
$version = array_map('intval', str_split($versionString, 2));
309312
/* Remove trailing zero */
310313
if (end($version) === 0) {
311314
$version = array_slice($version, 0, -1);

0 commit comments

Comments
 (0)