Skip to content

Commit 1eefe72

Browse files
Merge pull request #19025 from kamil-tekiela/intval
Replace function casts with normal casts
2 parents 856d316 + 54b5464 commit 1eefe72

35 files changed

Lines changed: 152 additions & 143 deletions

phpstan-baseline.neon

Lines changed: 66 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -2627,7 +2627,7 @@ parameters:
26272627

26282628
-
26292629
message: "#^Cannot cast mixed to int\\.$#"
2630-
count: 3
2630+
count: 4
26312631
path: src/Controllers/Import/ImportController.php
26322632

26332633
-
@@ -2690,11 +2690,6 @@ parameters:
26902690
count: 1
26912691
path: src/Controllers/Import/ImportController.php
26922692

2693-
-
2694-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
2695-
count: 1
2696-
path: src/Controllers/Import/ImportController.php
2697-
26982693
-
26992694
message: "#^Parameter \\#11 \\$sqlQuery of method PhpMyAdmin\\\\Sql\\:\\:executeQueryAndGetQueryResponse\\(\\) expects string, mixed given\\.$#"
27002695
count: 1
@@ -2856,7 +2851,7 @@ parameters:
28562851
path: src/Controllers/NavigationController.php
28572852

28582853
-
2859-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
2854+
message: "#^Cannot cast mixed to int\\.$#"
28602855
count: 1
28612856
path: src/Controllers/Normalization/CreateNewColumnController.php
28622857

@@ -3861,7 +3856,7 @@ parameters:
38613856
path: src/Controllers/Setup/ValidateController.php
38623857

38633858
-
3864-
message: "#^Parameter \\#1 \\$value of function strval expects bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
3859+
message: "#^Cannot cast mixed to string\\.$#"
38653860
count: 2
38663861
path: src/Controllers/Sql/EnumValuesController.php
38673862

@@ -3871,7 +3866,7 @@ parameters:
38713866
path: src/Controllers/Sql/RelationalValuesController.php
38723867

38733868
-
3874-
message: "#^Parameter \\#1 \\$value of function strval expects bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
3869+
message: "#^Cannot cast mixed to string\\.$#"
38753870
count: 2
38763871
path: src/Controllers/Sql/RelationalValuesController.php
38773872

@@ -4221,20 +4216,15 @@ parameters:
42214216
path: src/Controllers/Table/CreateController.php
42224217

42234218
-
4224-
message: "#^Only booleans are allowed in an if condition, PhpMyAdmin\\\\Dbal\\\\ResultInterface\\|false given\\.$#"
4225-
count: 1
4219+
message: "#^Cannot cast mixed to int\\.$#"
4220+
count: 5
42264221
path: src/Controllers/Table/CreateController.php
42274222

42284223
-
42294224
message: "#^Parameter \\#1 \\$string of function strlen expects string, mixed given\\.$#"
42304225
count: 1
42314226
path: src/Controllers/Table/CreateController.php
42324227

4233-
-
4234-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
4235-
count: 5
4236-
path: src/Controllers/Table/CreateController.php
4237-
42384228
-
42394229
message: "#^Parameter \\#3 \\$key of method PhpMyAdmin\\\\Transformations\\:\\:setMime\\(\\) expects string, mixed given\\.$#"
42404230
count: 1
@@ -4970,6 +4960,11 @@ parameters:
49704960
count: 1
49714961
path: src/Controllers/Table/SearchController.php
49724962

4963+
-
4964+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
4965+
count: 1
4966+
path: src/Controllers/Table/SearchController.php
4967+
49734968
-
49744969
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
49754970
count: 1
@@ -5580,11 +5575,21 @@ parameters:
55805575
count: 1
55815576
path: src/Controllers/Table/ZoomSearchController.php
55825577

5578+
-
5579+
message: "#^Cannot cast mixed to int\\.$#"
5580+
count: 1
5581+
path: src/Controllers/Table/ZoomSearchController.php
5582+
55835583
-
55845584
message: "#^Cannot cast mixed to string\\.$#"
55855585
count: 1
55865586
path: src/Controllers/Table/ZoomSearchController.php
55875587

5588+
-
5589+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
5590+
count: 1
5591+
path: src/Controllers/Table/ZoomSearchController.php
5592+
55885593
-
55895594
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
55905595
count: 2
@@ -5655,11 +5660,6 @@ parameters:
56555660
count: 1
56565661
path: src/Controllers/Table/ZoomSearchController.php
56575662

5658-
-
5659-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
5660-
count: 1
5661-
path: src/Controllers/Table/ZoomSearchController.php
5662-
56635663
-
56645664
message: "#^Parameter \\#2 \\$columnIndex of method PhpMyAdmin\\\\Controllers\\\\Table\\\\ZoomSearchController\\:\\:getColumnProperties\\(\\) expects int, int\\|false given\\.$#"
56655665
count: 1
@@ -6380,6 +6380,11 @@ parameters:
63806380
count: 7
63816381
path: src/Database/Events.php
63826382

6383+
-
6384+
message: "#^Cannot cast mixed to int\\.$#"
6385+
count: 1
6386+
path: src/Database/Events.php
6387+
63836388
-
63846389
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
63856390
count: 13
@@ -6420,11 +6425,6 @@ parameters:
64206425
count: 1
64216426
path: src/Database/Events.php
64226427

6423-
-
6424-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
6425-
count: 1
6426-
path: src/Database/Events.php
6427-
64286428
-
64296429
message: "#^Parameter \\#2 \\$string of function explode expects string, mixed given\\.$#"
64306430
count: 1
@@ -7042,6 +7042,11 @@ parameters:
70427042

70437043
-
70447044
message: "#^Cannot cast mixed to int\\.$#"
7045+
count: 6
7046+
path: src/Display/Results.php
7047+
7048+
-
7049+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
70457050
count: 1
70467051
path: src/Display/Results.php
70477052

@@ -7175,11 +7180,6 @@ parameters:
71757180
count: 2
71767181
path: src/Display/Results.php
71777182

7178-
-
7179-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
7180-
count: 5
7181-
path: src/Display/Results.php
7182-
71837183
-
71847184
message: "#^Parameter \\#1 \\$value of static method PhpMyAdmin\\\\Util\\:\\:formatNumber\\(\\) expects float\\|int\\|string, int\\|string\\|false given\\.$#"
71857185
count: 1
@@ -9595,6 +9595,11 @@ parameters:
95959595
count: 1
95969596
path: src/Normalization.php
95979597

9598+
-
9599+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
9600+
count: 1
9601+
path: src/Normalization.php
9602+
95989603
-
95999604
message: "#^Casting to string something that's already string\\.$#"
96009605
count: 1
@@ -10140,6 +10145,11 @@ parameters:
1014010145
count: 1
1014110146
path: src/Plugins/Auth/AuthenticationCookie.php
1014210147

10148+
-
10149+
message: "#^Cannot cast mixed to int\\.$#"
10150+
count: 1
10151+
path: src/Plugins/Auth/AuthenticationCookie.php
10152+
1014310153
-
1014410154
message: "#^Cannot cast mixed to string\\.$#"
1014510155
count: 1
@@ -10200,11 +10210,6 @@ parameters:
1020010210
count: 1
1020110211
path: src/Plugins/Auth/AuthenticationCookie.php
1020210212

10203-
-
10204-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
10205-
count: 1
10206-
path: src/Plugins/Auth/AuthenticationCookie.php
10207-
1020810213
-
1020910214
message: "#^Parameter \\#2 \\$remoteIp of method ReCaptcha\\\\ReCaptcha\\:\\:verify\\(\\) expects string\\|null, bool\\|string given\\.$#"
1021010215
count: 1
@@ -10315,23 +10320,28 @@ parameters:
1031510320
count: 1
1031610321
path: src/Plugins/AuthenticationPlugin.php
1031710322

10323+
-
10324+
message: "#^Cannot cast mixed to int\\.$#"
10325+
count: 1
10326+
path: src/Plugins/AuthenticationPlugin.php
10327+
1031810328
-
1031910329
message: "#^Cannot cast mixed to string\\.$#"
1032010330
count: 1
1032110331
path: src/Plugins/AuthenticationPlugin.php
1032210332

1032310333
-
10324-
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
10334+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
1032510335
count: 1
1032610336
path: src/Plugins/AuthenticationPlugin.php
1032710337

1032810338
-
10329-
message: "#^Parameter \\#1 \\$url of method PhpMyAdmin\\\\ResponseRenderer\\:\\:redirect\\(\\) expects non\\-empty\\-string, string given\\.$#"
10339+
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1033010340
count: 1
1033110341
path: src/Plugins/AuthenticationPlugin.php
1033210342

1033310343
-
10334-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
10344+
message: "#^Parameter \\#1 \\$url of method PhpMyAdmin\\\\ResponseRenderer\\:\\:redirect\\(\\) expects non\\-empty\\-string, string given\\.$#"
1033510345
count: 1
1033610346
path: src/Plugins/AuthenticationPlugin.php
1033710347

@@ -12311,7 +12321,7 @@ parameters:
1231112321
path: src/Plugins/Transformations/Abs/ExternalTransformationsPlugin.php
1231212322

1231312323
-
12314-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
12324+
message: "#^Cannot cast mixed to int\\.$#"
1231512325
count: 1
1231612326
path: src/Plugins/Transformations/Abs/HexTransformationsPlugin.php
1231712327

@@ -12321,7 +12331,7 @@ parameters:
1232112331
path: src/Plugins/Transformations/Abs/ImageLinkTransformationsPlugin.php
1232212332

1232312333
-
12324-
message: "#^Parameter \\#1 \\$value of function intval expects array\\|bool\\|float\\|int\\|resource\\|string\\|null, mixed given\\.$#"
12334+
message: "#^Cannot cast mixed to int\\.$#"
1232512335
count: 2
1232612336
path: src/Plugins/Transformations/Abs/ImageUploadTransformationsPlugin.php
1232712337

@@ -13500,6 +13510,16 @@ parameters:
1350013510
count: 1
1350113511
path: src/Server/Status/Processes.php
1350213512

13513+
-
13514+
message: "#^Method PhpMyAdmin\\\\Server\\\\SysInfo\\\\Linux\\:\\:memory\\(\\) should return array\\<string, int\\> but returns array\\<int\\>\\.$#"
13515+
count: 1
13516+
path: src/Server/SysInfo/Linux.php
13517+
13518+
-
13519+
message: "#^Parameter \\#1 \\$callback of function array_map expects \\(callable\\(mixed\\)\\: mixed\\)\\|null, Closure\\(array\\|bool\\|float\\|int\\|resource\\|string\\|null, int\\=\\)\\: int given\\.$#"
13520+
count: 1
13521+
path: src/Server/SysInfo/Linux.php
13522+
1350313523
-
1350413524
message: "#^Parameter \\#1 \\$keys of function array_combine expects array\\<int\\|string\\>, mixed given\\.$#"
1350513525
count: 1
@@ -13975,6 +13995,11 @@ parameters:
1397513995
count: 2
1397613996
path: src/Table/ColumnsDefinition.php
1397713997

13998+
-
13999+
message: "#^Casting to int something that's already int\\<1, max\\>\\.$#"
14000+
count: 1
14001+
path: src/Table/ColumnsDefinition.php
14002+
1397814003
-
1397914004
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
1398014005
count: 1

psalm-baseline.xml

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2924,20 +2924,12 @@
29242924
</UnusedParam>
29252925
</file>
29262926
<file src="src/Controllers/Sql/EnumValuesController.php">
2927-
<MixedArgument>
2928-
<code><![CDATA[$column]]></code>
2929-
<code><![CDATA[$currValue]]></code>
2930-
</MixedArgument>
29312927
<MixedAssignment>
29322928
<code><![CDATA[$column]]></code>
29332929
<code><![CDATA[$currValue]]></code>
29342930
</MixedAssignment>
29352931
</file>
29362932
<file src="src/Controllers/Sql/RelationalValuesController.php">
2937-
<MixedArgument>
2938-
<code><![CDATA[$column]]></code>
2939-
<code><![CDATA[$currValue]]></code>
2940-
</MixedArgument>
29412933
<MixedArrayAccess>
29422934
<code><![CDATA[$_SESSION['tmpval']['relational_display']]]></code>
29432935
</MixedArrayAccess>
@@ -3653,6 +3645,9 @@
36533645
<PossiblyUnusedMethod>
36543646
<code><![CDATA[getColumnProperties]]></code>
36553647
</PossiblyUnusedMethod>
3648+
<RedundantCastGivenDocblockType>
3649+
<code><![CDATA[(int) $config->settings['MaxRows']]]></code>
3650+
</RedundantCastGivenDocblockType>
36563651
<RiskyTruthyFalsyComparison>
36573652
<code><![CDATA[$searchColumnInForeigners]]></code>
36583653
<code><![CDATA[empty($row->collation)]]></code>
@@ -4032,6 +4027,12 @@
40324027
<code><![CDATA[$_POST['maxPlotLimit']]]></code>
40334028
<code><![CDATA[$_POST['where_clause']]]></code>
40344029
</PossiblyInvalidOperand>
4030+
<RedundantCastGivenDocblockType>
4031+
<code><![CDATA[(int) $config->settings['maxRowPlotLimit']]]></code>
4032+
</RedundantCastGivenDocblockType>
4033+
<RiskyCast>
4034+
<code><![CDATA[$_POST['maxPlotLimit']]]></code>
4035+
</RiskyCast>
40354036
<RiskyTruthyFalsyComparison>
40364037
<code><![CDATA[$searchColumnInForeigners]]></code>
40374038
<code><![CDATA[empty($_POST['maxPlotLimit'])]]></code>
@@ -4642,6 +4643,9 @@
46424643
<PossiblyUndefinedArrayOffset>
46434644
<code><![CDATA[$GLOBALS['errors']]]></code>
46444645
</PossiblyUndefinedArrayOffset>
4646+
<RiskyCast>
4647+
<code><![CDATA[$_POST['item_interval_value']]]></code>
4648+
</RiskyCast>
46454649
<RiskyTruthyFalsyComparison>
46464650
<code><![CDATA[empty($_POST['editor_process_edit'])]]></code>
46474651
<code><![CDATA[empty($_POST['item_comment'])]]></code>
@@ -5350,6 +5354,9 @@
53505354
<code><![CDATA[$o->expr->expr]]></code>
53515355
<code><![CDATA[$order->expr->column]]></code>
53525356
</PossiblyNullPropertyFetch>
5357+
<RedundantCastGivenDocblockType>
5358+
<code><![CDATA[(int) $this->config->settings['MaxRows']]]></code>
5359+
</RedundantCastGivenDocblockType>
53535360
<RedundantCondition>
53545361
<code><![CDATA[! empty($added[$orgFullTableName])]]></code>
53555362
<code><![CDATA[empty($statementInfo->statement->from)]]></code>
@@ -7098,6 +7105,9 @@
70987105
<RedundantCast>
70997106
<code><![CDATA[(string) $dependon]]></code>
71007107
</RedundantCast>
7108+
<RedundantCastGivenDocblockType>
7109+
<code><![CDATA[(int) $this->config->settings['MaxRows']]]></code>
7110+
</RedundantCastGivenDocblockType>
71017111
<RiskyTruthyFalsyComparison>
71027112
<code><![CDATA[$dropCols]]></code>
71037113
</RiskyTruthyFalsyComparison>
@@ -7554,6 +7564,9 @@
75547564
<RedundantCast>
75557565
<code><![CDATA[(string) $GLOBALS['conn_error']]]></code>
75567566
</RedundantCast>
7567+
<RiskyCast>
7568+
<code><![CDATA[$_GET['session_expired']]]></code>
7569+
</RiskyCast>
75577570
<RiskyTruthyFalsyComparison>
75587571
<code><![CDATA[empty($GLOBALS['conn_error'])]]></code>
75597572
<code><![CDATA[empty($_POST[$config->settings['CaptchaResponseParam']])]]></code>
@@ -7640,6 +7653,12 @@
76407653
<PossiblyInvalidCast>
76417654
<code><![CDATA[$_REQUEST['guid']]]></code>
76427655
</PossiblyInvalidCast>
7656+
<RedundantCastGivenDocblockType>
7657+
<code><![CDATA[(int) Config::getInstance()->settings['LoginCookieValidity']]]></code>
7658+
</RedundantCastGivenDocblockType>
7659+
<RiskyCast>
7660+
<code><![CDATA[$_REQUEST['access_time']]]></code>
7661+
</RiskyCast>
76437662
</file>
76447663
<file src="src/Plugins/AuthenticationPluginFactory.php">
76457664
<DeprecatedMethod>
@@ -10987,6 +11006,9 @@
1098711006
<PossiblyUndefinedArrayOffset>
1098811007
<code><![CDATA[$columnMeta['DefaultValue']]]></code>
1098911008
</PossiblyUndefinedArrayOffset>
11009+
<RedundantCastGivenDocblockType>
11010+
<code><![CDATA[(int) $config->settings['MaxRows']]]></code>
11011+
</RedundantCastGivenDocblockType>
1099011012
<RiskyTruthyFalsyComparison>
1099111013
<code><![CDATA[! $columnMeta['column_status']['isEditable']]]></code>
1099211014
<code><![CDATA[! $columnMeta['column_status']['isEditable']]]></code>

0 commit comments

Comments
 (0)