Skip to content

Commit 7968818

Browse files
committed
Fix baselines and solve some reviews.
1 parent 86223e7 commit 7968818

File tree

3 files changed

+28
-22
lines changed

3 files changed

+28
-22
lines changed

phpstan-baseline.neon

Lines changed: 19 additions & 9 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 \\$array of function implode expects array\\|null, array\\<string\\>\\|string given\\.$#"
129+
message: "#^Parameter \\#2 \\$pieces of function implode expects array, 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 \\$string2 of function strcasecmp expects string, mixed given\\.$#"
319+
message: "#^Parameter \\#2 \\$str2 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 \\$array of function implode expects array\\|null, array\\<string\\>\\|string given\\.$#"
414+
message: "#^Parameter \\#2 \\$pieces of function implode expects array, array\\<string\\>\\|string given\\.$#"
415415
count: 1
416416
path: src/Components/Reference.php
417417

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

803803
-
804-
message: "#^Parameter \\#2 \\.\\.\\.\\$arrays of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
804+
message: "#^Parameter \\#2 \\.\\.\\.\\$args of function array_merge expects array, array\\<int, string\\>\\|false given\\.$#"
805805
count: 1
806806
path: src/Tools/ContextGenerator.php
807807

@@ -816,12 +816,12 @@ parameters:
816816
path: src/Tools/TestGenerator.php
817817

818818
-
819-
message: "#^Parameter \\#1 \\$directory of function mkdir expects string, string\\|null given\\.$#"
819+
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, string\\|null given\\.$#"
820820
count: 1
821821
path: src/Tools/TestGenerator.php
822822

823823
-
824-
message: "#^Parameter \\#1 \\$filename of function is_dir expects string, string\\|null given\\.$#"
824+
message: "#^Parameter \\#1 \\$pathname of function mkdir expects string, string\\|null given\\.$#"
825825
count: 1
826826
path: src/Tools/TestGenerator.php
827827

@@ -906,7 +906,7 @@ parameters:
906906
path: src/Utils/Formatter.php
907907

908908
-
909-
message: "#^Parameter \\#1 \\$string of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
909+
message: "#^Parameter \\#1 \\$input of function str_repeat expects string, array\\<int, array\\<string, int\\|string\\>\\>\\|bool\\|string given\\.$#"
910910
count: 1
911911
path: src/Utils/Formatter.php
912912

@@ -961,7 +961,7 @@ parameters:
961961
path: src/Utils/Routine.php
962962

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

@@ -991,7 +991,7 @@ parameters:
991991
path: src/Utils/Tokens.php
992992

993993
-
994-
message: "#^Parameter \\#1 \\$string1 of function strcasecmp expects string, int\\|string given\\.$#"
994+
message: "#^Parameter \\#1 \\$str1 of function strcasecmp expects string, int\\|string given\\.$#"
995995
count: 1
996996
path: src/Utils/Tokens.php
997997

@@ -1125,6 +1125,16 @@ parameters:
11251125
count: 1
11261126
path: tests/Parser/WithStatementTest.php
11271127

1128+
-
1129+
message: "#^Cannot access offset int\\<0, max\\> on non\\-empty\\-array\\<int, string\\>\\|false\\.$#"
1130+
count: 1
1131+
path: tests/Utils/BufferedQueryTest.php
1132+
1133+
-
1134+
message: "#^Parameter \\#1 \\$var of function count expects array\\|Countable, array\\<int, string\\>\\|false given\\.$#"
1135+
count: 1
1136+
path: tests/Utils/BufferedQueryTest.php
1137+
11281138
-
11291139
message: "#^Parameter \\#1 \\$statement of static method PhpMyAdmin\\\\SqlParser\\\\Utils\\\\Misc\\:\\:getAliases\\(\\) expects PhpMyAdmin\\\\SqlParser\\\\Statements\\\\SelectStatement, PhpMyAdmin\\\\SqlParser\\\\Statement\\|null given\\.$#"
11301140
count: 1

psalm-baseline.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -656,6 +656,9 @@
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>
659662
<file src="src/Lexer.php">
660663
<LoopInvalidation occurrences="3">
661664
<code>$this-&gt;last</code>

src/Tools/ContextGenerator.php

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
use function basename;
1414
use function count;
1515
use function dirname;
16-
use function end;
16+
use function file;
1717
use function file_put_contents;
1818
use function implode;
1919
use function ksort;
@@ -171,8 +171,8 @@ public static function readWords(array $files)
171171
{
172172
/** @psalm-var list<string> $words */
173173
$words = [];
174-
foreach (array_map('file', $files) as $wordsByFile) {
175-
$words = array_merge($words, $wordsByFile);
174+
foreach ($files as $file) {
175+
$words = array_merge($words, file($file));
176176
}
177177

178178
/** @var array<string, int> $types */
@@ -229,21 +229,14 @@ public static function printWords(array $words): string
229229
$ret = '';
230230
foreach ($words as $type => $wordsByType) {
231231
foreach ($wordsByType as $word) {
232-
$ret .= sprintf(" '%s' => %s,\n", $word, self::numTypeToConst($type));
232+
$ret .= sprintf(" '%s' => %s,\n", $word, self::translateIntTypeToTextConstant($type));
233233
}
234234
}
235235

236236
return $ret;
237237
}
238238

239-
/**
240-
* Convert a numeric value representing a set of const to a textual const value.
241-
*
242-
* @param int $type The numeric value.
243-
*
244-
* @return string The text to write considering the given numeric value.
245-
*/
246-
private static function numTypeToConst(int $type): string
239+
private static function translateIntTypeToTextConstant(int $type): string
247240
{
248241
$matchingFlags = array_filter(
249242
self::$typesNumToConst,
@@ -310,7 +303,7 @@ public static function formatName($name)
310303

311304
$version = array_map('intval', str_split($versionString, 2));
312305
/* Remove trailing zero */
313-
if (end($version) === 0) {
306+
if ($version[count($version) - 1] === 0) {
314307
$version = array_slice($version, 0, -1);
315308
}
316309

0 commit comments

Comments
 (0)