Skip to content

Commit a1a778d

Browse files
committed
Fix some issues reported by PHPStan
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
1 parent c0eb02d commit a1a778d

4 files changed

Lines changed: 12 additions & 56 deletions

File tree

libraries/classes/Command/CacheWarmupCommand.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use PhpMyAdmin\Tests\Stubs\DbiDummy;
1212
use RecursiveDirectoryIterator;
1313
use RecursiveIteratorIterator;
14+
use SplFileInfo;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputArgument;
1617
use Symfony\Component\Console\Input\InputInterface;
@@ -143,6 +144,7 @@ private function warmUpTwigCache(
143144
);
144145

145146
$output->writeln('Warming templates', OutputInterface::VERBOSITY_VERY_VERBOSE);
147+
/** @var SplFileInfo $file */
146148
foreach ($templates as $file) {
147149
// Skip test files
148150
if (str_contains($file->getPathname(), '/test/')) {

libraries/classes/Controllers/Transformation/WrapperController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,10 @@ public function __invoke(): void
155155
. ($mime_options['charset'] ?? '');
156156
}
157157

158-
Core::downloadHeader($cn ?? '', $mime_type ?? '');
158+
Core::downloadHeader($cn ?? '', $mime_type);
159159

160160
if (! isset($_REQUEST['resize'])) {
161-
if (stripos($mime_type ?? '', 'html') === false) {
161+
if (stripos($mime_type, 'html') === false) {
162162
echo $row[$transform_key];
163163
} else {
164164
echo htmlspecialchars($row[$transform_key]);

phpstan-baseline.neon

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2835,19 +2835,9 @@ parameters:
28352835
count: 1
28362836
path: libraries/classes/Dbal/DbiMysqli.php
28372837

2838-
-
2839-
message: "#^Method PhpMyAdmin\\\\Dbal\\\\MysqliResult\\:\\:__construct\\(\\) has parameter \\$result with no value type specified in iterable type mysqli_result\\.$#"
2840-
count: 1
2841-
path: libraries/classes/Dbal/MysqliResult.php
2842-
28432838
-
28442839
message: "#^Method PhpMyAdmin\\\\Dbal\\\\MysqliResult\\:\\:fetchAllKeyPair\\(\\) should return array\\<string, string\\|null\\> but returns array\\<int\\|string, mixed\\>\\.$#"
2845-
count: 1
2846-
path: libraries/classes/Dbal/MysqliResult.php
2847-
2848-
-
2849-
message: "#^Property PhpMyAdmin\\\\Dbal\\\\MysqliResult\\:\\:\\$result type has no value type specified in iterable type mysqli_result\\.$#"
2850-
count: 1
2840+
count: 2
28512841
path: libraries/classes/Dbal/MysqliResult.php
28522842

28532843
-
@@ -3125,11 +3115,6 @@ parameters:
31253115
count: 1
31263116
path: libraries/classes/Display/Results.php
31273117

3128-
-
3129-
message: "#^Method PhpMyAdmin\\\\Display\\\\Results\\:\\:setParamForLinkForeignKeyRelatedTables\\(\\) should return array\\<string, array\\<string\\>\\> but returns array\\<int\\|string, array\\>\\.$#"
3130-
count: 1
3131-
path: libraries/classes/Display/Results.php
3132-
31333118
-
31343119
message: "#^Offset 3 does not exist on array\\{string\\|null, string\\|null, string\\|null\\}\\.$#"
31353120
count: 1
@@ -6305,11 +6290,6 @@ parameters:
63056290
count: 1
63066291
path: libraries/classes/Plugins/Schema/Dia/Dia.php
63076292

6308-
-
6309-
message: "#^Parameter \\#2 \\$masterField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Dia\\\\DiaRelationSchema\\:\\:addRelation\\(\\) expects string, int\\|string given\\.$#"
6310-
count: 1
6311-
path: libraries/classes/Plugins/Schema/Dia/DiaRelationSchema.php
6312-
63136293
-
63146294
message: "#^Binary operation \"\\+\" between int\\|string\\|false and 12 results in an error\\.$#"
63156295
count: 4
@@ -6330,11 +6310,6 @@ parameters:
63306310
count: 1
63316311
path: libraries/classes/Plugins/Schema/Eps/EpsRelationSchema.php
63326312

6333-
-
6334-
message: "#^Parameter \\#4 \\$masterField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Eps\\\\EpsRelationSchema\\:\\:addRelation\\(\\) expects string, int\\|string given\\.$#"
6335-
count: 1
6336-
path: libraries/classes/Plugins/Schema/Eps/EpsRelationSchema.php
6337-
63386313
-
63396314
message: "#^Call to an undefined method object\\:\\:line\\(\\)\\.$#"
63406315
count: 7
@@ -6390,11 +6365,6 @@ parameters:
63906365
count: 1
63916366
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
63926367

6393-
-
6394-
message: "#^Parameter \\#2 \\$masterField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:addRelation\\(\\) expects string, int\\|string given\\.$#"
6395-
count: 1
6396-
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
6397-
63986368
-
63996369
message: "#^Parameter \\#2 \\$master_table of class PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\RelationStatsPdf constructor expects string, PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\TableStatsPdf given\\.$#"
64006370
count: 1
@@ -6445,6 +6415,11 @@ parameters:
64456415
count: 1
64466416
path: libraries/classes/Plugins/Schema/Pdf/TableStatsPdf.php
64476417

6418+
-
6419+
message: "#^Binary operation \"\\+\" between int\\|string\\|false and 1\\.5 results in an error\\.$#"
6420+
count: 1
6421+
path: libraries/classes/Plugins/Schema/RelationStats.php
6422+
64486423
-
64496424
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Schema\\\\RelationStats\\:\\:getXy\\(\\) return type has no value type specified in iterable type array\\.$#"
64506425
count: 1
@@ -6500,11 +6475,6 @@ parameters:
65006475
count: 1
65016476
path: libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php
65026477

6503-
-
6504-
message: "#^Parameter \\#4 \\$masterField of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\SvgRelationSchema\\:\\:addRelation\\(\\) expects string, int\\|string given\\.$#"
6505-
count: 1
6506-
path: libraries/classes/Plugins/Schema/Svg/SvgRelationSchema.php
6507-
65086478
-
65096479
message: "#^Parameter \\#4 \\$y of method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Svg\\\\Svg\\:\\:startSvgDoc\\(\\) expects int, float\\|int given\\.$#"
65106480
count: 1

psalm-baseline.xml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -174,21 +174,6 @@
174174
<code>$row[0]</code>
175175
</PossiblyNullArgument>
176176
</file>
177-
<file src="libraries/classes/Command/CacheWarmupCommand.php">
178-
<MixedArgument occurrences="2">
179-
<code>$file-&gt;getPathname()</code>
180-
<code>$file-&gt;getPathname()</code>
181-
</MixedArgument>
182-
<MixedAssignment occurrences="1">
183-
<code>$file</code>
184-
</MixedAssignment>
185-
<MixedMethodCall occurrences="4">
186-
<code>getExtension</code>
187-
<code>getPathname</code>
188-
<code>getPathname</code>
189-
<code>isFile</code>
190-
</MixedMethodCall>
191-
</file>
192177
<file src="libraries/classes/Command/FixPoTwigCommand.php">
193178
<MixedArrayAccess occurrences="3">
194179
<code>$replace[0]</code>
@@ -4001,14 +3986,13 @@
40013986
</MixedAssignment>
40023987
</file>
40033988
<file src="libraries/classes/Controllers/Transformation/WrapperController.php">
4004-
<MixedArgument occurrences="12">
3989+
<MixedArgument occurrences="11">
40053990
<code>$_GET['where_clause_sign'] ?? ''</code>
40063991
<code>$cn ?? ''</code>
40073992
<code>$db</code>
40083993
<code>$mime_map[$transform_key]['mimetype']</code>
40093994
<code>$mime_map[$transform_key]['transformation_options'] ?? ''</code>
4010-
<code>$mime_type ?? ''</code>
4011-
<code>$mime_type ?? ''</code>
3995+
<code>$mime_type</code>
40123996
<code>$option</code>
40133997
<code>$srcHeight / $ratioWidth</code>
40143998
<code>$srcWidth / $ratioHeight</code>

0 commit comments

Comments
 (0)