Skip to content

Commit c351696

Browse files
Merge pull request #18094 from kamil-tekiela/new-phpstan-checks
New phpstan checks
2 parents e854e79 + c9f2928 commit c351696

4 files changed

Lines changed: 194 additions & 12 deletions

File tree

libraries/classes/Dbal/MysqliResult.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Webmozart\Assert\Assert;
1414

1515
use function array_column;
16+
use function array_key_exists;
1617
use function is_array;
1718
use function is_bool;
1819
use function is_string;
@@ -104,7 +105,11 @@ public function fetchValue($field = 0)
104105
$row = $this->fetchRow();
105106
}
106107

107-
return $row[$field] ?? false;
108+
if (! array_key_exists($field, $row)) {
109+
return false;
110+
}
111+
112+
return $row[$field];
108113
}
109114

110115
/**

phpstan-baseline.neon

Lines changed: 175 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -895,6 +895,21 @@ parameters:
895895
count: 1
896896
path: libraries/classes/ConfigStorage/Relation.php
897897

898+
-
899+
message: "#^Foreach overwrites \\$feature with its value variable\\.$#"
900+
count: 1
901+
path: libraries/classes/ConfigStorage/Relation.php
902+
903+
-
904+
message: "#^Foreach overwrites \\$table with its key variable\\.$#"
905+
count: 1
906+
path: libraries/classes/ConfigStorage/Relation.php
907+
908+
-
909+
message: "#^Foreach overwrites \\$work with its key variable\\.$#"
910+
count: 1
911+
path: libraries/classes/ConfigStorage/Relation.php
912+
898913
-
899914
message: "#^Method PhpMyAdmin\\\\ConfigStorage\\\\Relation\\:\\:buildForeignDropdown\\(\\) has parameter \\$foreign with no value type specified in iterable type array\\.$#"
900915
count: 1
@@ -2390,6 +2405,11 @@ parameters:
23902405
count: 1
23912406
path: libraries/classes/Controllers/Table/Structure/SaveController.php
23922407

2408+
-
2409+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
2410+
count: 2
2411+
path: libraries/classes/Controllers/Table/Structure/SaveController.php
2412+
23932413
-
23942414
message: "#^Method PhpMyAdmin\\\\Controllers\\\\Table\\\\Structure\\\\SaveController\\:\\:adjustColumnPrivileges\\(\\) has parameter \\$adjust_privileges with no value type specified in iterable type array\\.$#"
23952415
count: 1
@@ -2870,6 +2890,11 @@ parameters:
28702890
count: 1
28712891
path: libraries/classes/Database/Qbe.php
28722892

2893+
-
2894+
message: "#^For loop initial assignment overwrites variable \\$columnIndex\\.$#"
2895+
count: 1
2896+
path: libraries/classes/Database/Qbe.php
2897+
28732898
-
28742899
message: "#^Method PhpMyAdmin\\\\Database\\\\Qbe\\:\\:__construct\\(\\) has parameter \\$savedSearchList with no value type specified in iterable type array\\.$#"
28752900
count: 1
@@ -3170,6 +3195,11 @@ parameters:
31703195
count: 1
31713196
path: libraries/classes/Database/Routines.php
31723197

3198+
-
3199+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
3200+
count: 2
3201+
path: libraries/classes/Database/Routines.php
3202+
31733203
-
31743204
message: "#^Method PhpMyAdmin\\\\Database\\\\Routines\\:\\:backupPrivileges\\(\\) return type has no value type specified in iterable type array\\.$#"
31753205
count: 1
@@ -3570,6 +3600,36 @@ parameters:
35703600
count: 1
35713601
path: libraries/classes/Dbal/MysqliResult.php
35723602

3603+
-
3604+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$expr\\.$#"
3605+
count: 1
3606+
path: libraries/classes/Display/Results.php
3607+
3608+
-
3609+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$from\\.$#"
3610+
count: 2
3611+
path: libraries/classes/Display/Results.php
3612+
3613+
-
3614+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$limit\\.$#"
3615+
count: 1
3616+
path: libraries/classes/Display/Results.php
3617+
3618+
-
3619+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$where\\.$#"
3620+
count: 1
3621+
path: libraries/classes/Display/Results.php
3622+
3623+
-
3624+
message: "#^Access to an undefined property object\\:\\:\\$column\\.$#"
3625+
count: 1
3626+
path: libraries/classes/Display/Results.php
3627+
3628+
-
3629+
message: "#^Access to an undefined property object\\:\\:\\$database\\.$#"
3630+
count: 1
3631+
path: libraries/classes/Display/Results.php
3632+
35733633
-
35743634
message: "#^Cannot access offset int\\<0, max\\> on mixed\\.$#"
35753635
count: 2
@@ -4545,6 +4605,11 @@ parameters:
45454605
count: 1
45464606
path: libraries/classes/Gis/GisMultiPolygon.php
45474607

4608+
-
4609+
message: "#^Variable \\$label_point in isset\\(\\) always exists and is not nullable\\.$#"
4610+
count: 2
4611+
path: libraries/classes/Gis/GisMultiPolygon.php
4612+
45484613
-
45494614
message: "#^Method PhpMyAdmin\\\\Gis\\\\GisPoint\\:\\:generateParams\\(\\) return type has no value type specified in iterable type array\\.$#"
45504615
count: 1
@@ -4840,11 +4905,6 @@ parameters:
48404905
count: 2
48414906
path: libraries/classes/Git.php
48424907

4843-
-
4844-
message: "#^Variable \\$position might not be defined\\.$#"
4845-
count: 1
4846-
path: libraries/classes/Git.php
4847-
48484908
-
48494909
message: "#^Method PhpMyAdmin\\\\Header\\:\\:getJsParams\\(\\) return type has no value type specified in iterable type array\\.$#"
48504910
count: 1
@@ -4945,6 +5005,11 @@ parameters:
49455005
count: 2
49465006
path: libraries/classes/Import.php
49475007

5008+
-
5009+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
5010+
count: 5
5011+
path: libraries/classes/Import.php
5012+
49485013
-
49495014
message: "#^Foreach overwrites \\$sqlQuery with its value variable\\.$#"
49505015
count: 1
@@ -5015,6 +5080,11 @@ parameters:
50155080
count: 2
50165081
path: libraries/classes/Import.php
50175082

5083+
-
5084+
message: "#^Parameter \\#1 \\$sql of method PhpMyAdmin\\\\Import\\:\\:executeQuery\\(\\) expects string, string\\|null given\\.$#"
5085+
count: 1
5086+
path: libraries/classes/Import.php
5087+
50185088
-
50195089
message: "#^Parameter \\#1 \\$sql of method PhpMyAdmin\\\\Import\\:\\:runQuery\\(\\) expects string, \\(array\\<int, string\\>\\|string\\|null\\) given\\.$#"
50205090
count: 1
@@ -5625,6 +5695,11 @@ parameters:
56255695
count: 1
56265696
path: libraries/classes/Navigation/Navigation.php
56275697

5698+
-
5699+
message: "#^Access to an undefined property PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\:\\:\\$secondIcon\\.$#"
5700+
count: 2
5701+
path: libraries/classes/Navigation/NavigationTree.php
5702+
56285703
-
56295704
message: "#^Cannot access property \\$pos2 on PhpMyAdmin\\\\Navigation\\\\Nodes\\\\Node\\|null\\.$#"
56305705
count: 1
@@ -6235,6 +6310,11 @@ parameters:
62356310
count: 1
62366311
path: libraries/classes/Plugins/Export/ExportLatex.php
62376312

6313+
-
6314+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
6315+
count: 3
6316+
path: libraries/classes/Plugins/Export/ExportMediawiki.php
6317+
62386318
-
62396319
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportMediawiki\\:\\:exportData\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
62406320
count: 1
@@ -6345,6 +6425,11 @@ parameters:
63456425
count: 2
63466426
path: libraries/classes/Plugins/Export/ExportSql.php
63476427

6428+
-
6429+
message: "#^Foreach overwrites \\$j with its key variable\\.$#"
6430+
count: 1
6431+
path: libraries/classes/Plugins/Export/ExportSql.php
6432+
63486433
-
63496434
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\ExportSql\\:\\:exportData\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
63506435
count: 1
@@ -6490,6 +6575,16 @@ parameters:
64906575
count: 1
64916576
path: libraries/classes/Plugins/Export/ExportYaml.php
64926577

6578+
-
6579+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
6580+
count: 1
6581+
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
6582+
6583+
-
6584+
message: "#^Foreach overwrites \\$width with its value variable\\.$#"
6585+
count: 2
6586+
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
6587+
64936588
-
64946589
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\Helpers\\\\Pdf\\:\\:getTableDef\\(\\) has parameter \\$aliases with no value type specified in iterable type array\\.$#"
64956590
count: 1
@@ -6565,11 +6660,6 @@ parameters:
65656660
count: 1
65666661
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
65676662

6568-
-
6569-
message: "#^Variable \\$columns_cnt might not be defined\\.$#"
6570-
count: 6
6571-
path: libraries/classes/Plugins/Export/Helpers/Pdf.php
6572-
65736663
-
65746664
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Export\\\\Helpers\\\\TableProperty\\:\\:__construct\\(\\) has parameter \\$row with no value type specified in iterable type array\\.$#"
65756665
count: 1
@@ -6705,6 +6795,11 @@ parameters:
67056795
count: 1
67066796
path: libraries/classes/Plugins/Import/ImportMediawiki.php
67076797

6798+
-
6799+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
6800+
count: 2
6801+
path: libraries/classes/Plugins/Import/ImportOds.php
6802+
67086803
-
67096804
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\ImportOds\\:\\:iterateOverColumns\\(\\) has parameter \\$col_names with no value type specified in iterable type array\\.$#"
67106805
count: 1
@@ -6805,6 +6900,11 @@ parameters:
68056900
count: 1
68066901
path: libraries/classes/Plugins/Import/ImportXml.php
68076902

6903+
-
6904+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
6905+
count: 1
6906+
path: libraries/classes/Plugins/Import/ImportXml.php
6907+
68086908
-
68096909
message: "#^Offset 'charset' does not exist on SimpleXMLElement\\|null\\.$#"
68106910
count: 1
@@ -6840,6 +6940,11 @@ parameters:
68406940
count: 1
68416941
path: libraries/classes/Plugins/Import/ImportXml.php
68426942

6943+
-
6944+
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\ShapeFileImport\\:\\:readSHP\\(\\) never returns false so it can be removed from the return type\\.$#"
6945+
count: 1
6946+
path: libraries/classes/Plugins/Import/ShapeFileImport.php
6947+
68436948
-
68446949
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Import\\\\Upload\\\\UploadNoplugin\\:\\:getUploadStatus\\(\\) return type has no value type specified in iterable type array\\.$#"
68456950
count: 1
@@ -6925,6 +7030,11 @@ parameters:
69257030
count: 2
69267031
path: libraries/classes/Plugins/Schema/Eps/TableStatsEps.php
69277032

7033+
-
7034+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
7035+
count: 1
7036+
path: libraries/classes/Plugins/Schema/Pdf/Pdf.php
7037+
69287038
-
69297039
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\Pdf\\:\\:row\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
69307040
count: 1
@@ -6960,6 +7070,11 @@ parameters:
69607070
count: 2
69617071
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
69627072

7073+
-
7074+
message: "#^For loop initial assignment overwrites variable \\$size\\.$#"
7075+
count: 1
7076+
path: libraries/classes/Plugins/Schema/Pdf/PdfRelationSchema.php
7077+
69637078
-
69647079
message: "#^Method PhpMyAdmin\\\\Plugins\\\\Schema\\\\Pdf\\\\PdfRelationSchema\\:\\:dataDictionaryDoc\\(\\) has parameter \\$alltables with no value type specified in iterable type array\\.$#"
69657080
count: 1
@@ -7950,6 +8065,11 @@ parameters:
79508065
count: 1
79518066
path: libraries/classes/Server/Privileges.php
79528067

8068+
-
8069+
message: "#^Access to an uninitialized property PhpMyAdmin\\\\Server\\\\Status\\\\Data\\:\\:\\$replicationInfo\\.$#"
8070+
count: 2
8071+
path: libraries/classes/Server/Status/Data.php
8072+
79538073
-
79548074
message: "#^Method PhpMyAdmin\\\\Server\\\\Status\\\\Data\\:\\:calculateValues\\(\\) has parameter \\$server_status with no value type specified in iterable type array\\.$#"
79558075
count: 1
@@ -8300,6 +8420,11 @@ parameters:
83008420
count: 1
83018421
path: libraries/classes/Sql.php
83028422

8423+
-
8424+
message: "#^Access to an undefined property PhpMyAdmin\\\\SqlParser\\\\Statement\\:\\:\\$where\\.$#"
8425+
count: 1
8426+
path: libraries/classes/Sql.php
8427+
83038428
-
83048429
message: "#^Method PhpMyAdmin\\\\Sql\\:\\:countQueryResults\\(\\) should return int\\|numeric\\-string but returns mixed\\.$#"
83058430
count: 1
@@ -8540,6 +8665,11 @@ parameters:
85408665
count: 5
85418666
path: libraries/classes/Table.php
85428667

8668+
-
8669+
message: "#^Foreach overwrites \\$trigger with its value variable\\.$#"
8670+
count: 1
8671+
path: libraries/classes/Table.php
8672+
85438673
-
85448674
message: "#^Method PhpMyAdmin\\\\Table\\:\\:duplicateInfo\\(\\) has parameter \\$getFields with no value type specified in iterable type array\\.$#"
85458675
count: 1
@@ -8910,6 +9040,11 @@ parameters:
89109040
count: 1
89119041
path: libraries/classes/Tracker.php
89129042

9043+
-
9044+
message: "#^Foreach overwrites \\$logEntry with its value variable\\.$#"
9045+
count: 1
9046+
path: libraries/classes/Tracker.php
9047+
89139048
-
89149049
message: "#^Method PhpMyAdmin\\\\Tracker\\:\\:changeTrackingData\\(\\) has parameter \\$newData with no value type specified in iterable type array\\.$#"
89159050
count: 1
@@ -9190,6 +9325,11 @@ parameters:
91909325
count: 1
91919326
path: libraries/classes/Tracking.php
91929327

9328+
-
9329+
message: "#^Foreach overwrites \\$file with its value variable\\.$#"
9330+
count: 1
9331+
path: libraries/classes/Transformations.php
9332+
91939333
-
91949334
message: "#^Method PhpMyAdmin\\\\Transformations\\:\\:getAvailableMimeTypes\\(\\) return type has no value type specified in iterable type array\\.$#"
91959335
count: 1
@@ -9325,6 +9465,11 @@ parameters:
93259465
count: 5
93269466
path: libraries/classes/Util.php
93279467

9468+
-
9469+
message: "#^For loop initial assignment overwrites variable \\$i\\.$#"
9470+
count: 1
9471+
path: libraries/classes/Util.php
9472+
93289473
-
93299474
message: "#^Foreach overwrites \\$quote with its value variable\\.$#"
93309475
count: 1
@@ -9495,6 +9640,21 @@ parameters:
94959640
count: 1
94969641
path: libraries/classes/Utils/HttpRequest.php
94979642

9643+
-
9644+
message: "#^Access to an undefined property object\\:\\:\\$date\\.$#"
9645+
count: 1
9646+
path: libraries/classes/VersionInformation.php
9647+
9648+
-
9649+
message: "#^Access to an undefined property object\\:\\:\\$releases\\.$#"
9650+
count: 1
9651+
path: libraries/classes/VersionInformation.php
9652+
9653+
-
9654+
message: "#^Access to an undefined property object\\:\\:\\$version\\.$#"
9655+
count: 1
9656+
path: libraries/classes/VersionInformation.php
9657+
94989658
-
94999659
message: "#^Comparison operation \"\\>\\=\" between int\\<1, max\\> and 1 is always true\\.$#"
95009660
count: 1
@@ -11700,6 +11860,11 @@ parameters:
1170011860
count: 1
1170111861
path: test/classes/StorageEngineTest.php
1170211862

11863+
-
11864+
message: "#^Method PhpMyAdmin\\\\Tests\\\\Stubs\\\\DbiDummy\\:\\:connect\\(\\) never returns null so it can be removed from the return type\\.$#"
11865+
count: 1
11866+
path: test/classes/Stubs/DbiDummy.php
11867+
1170311868
-
1170411869
message: "#^Method PhpMyAdmin\\\\Tests\\\\Stubs\\\\DbiDummy\\:\\:fetchAny\\(\\) return type has no value type specified in iterable type array\\.$#"
1170511870
count: 1

0 commit comments

Comments
 (0)