Skip to content

Commit 8cc6db1

Browse files
Merge pull request #18622 from kamil-tekiela/Remove-recasts
Remove redundant casts
2 parents 895c118 + 00367fb commit 8cc6db1

File tree

6 files changed

+4
-38
lines changed

6 files changed

+4
-38
lines changed

libraries/classes/ConfigStorage/Relation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1461,8 +1461,7 @@ public function getCreateTableSqlQueries(array $tableNameReplacements): array
14611461
continue;
14621462
}
14631463

1464-
// The following redundant cast is needed for PHPStan
1465-
$tableName = (string) $table[1];
1464+
$tableName = $table[1];
14661465

14671466
// Replace the table name with another one
14681467
if (isset($tableNameReplacements[$tableName])) {

libraries/classes/Controllers/Database/Structure/ReplacePrefixController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function __invoke(ServerRequest $request): void
4242
$subFromPrefix = mb_substr($current, 0, mb_strlen((string) $fromPrefix));
4343

4444
if ($subFromPrefix === $fromPrefix) {
45-
$newTableName = $toPrefix . mb_substr($current, mb_strlen((string) $fromPrefix));
45+
$newTableName = $toPrefix . mb_substr($current, mb_strlen($fromPrefix));
4646
} else {
4747
$newTableName = $current;
4848
}

libraries/classes/Dbal/DbiMysqli.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ public function getProtoInfo(Connection $connection): int
272272
$mysqli = $connection->connection;
273273

274274
// phpcs:ignore Squiz.NamingConventions.ValidVariableName.MemberNotCamelCaps
275-
return (int) $mysqli->protocol_version;
275+
return $mysqli->protocol_version;
276276
}
277277

278278
/**

libraries/classes/Sanitize.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ public static function removeRequestVars(array $allowList): void
276276
// and use type casting because the variables could have become
277277
// strings
278278
$keys = array_keys(
279-
array_merge((array) $_REQUEST, (array) $_GET, (array) $_POST, (array) $_COOKIE),
279+
array_merge($_REQUEST, $_GET, $_POST, $_COOKIE),
280280
);
281281

282282
foreach ($keys as $key) {

phpstan-baseline.neon

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1555,11 +1555,6 @@ parameters:
15551555
count: 1
15561556
path: libraries/classes/ConfigStorage/Relation.php
15571557

1558-
-
1559-
message: "#^Casting to string something that's already string\\.$#"
1560-
count: 1
1561-
path: libraries/classes/ConfigStorage/Relation.php
1562-
15631558
-
15641559
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
15651560
count: 23
@@ -3540,11 +3535,6 @@ parameters:
35403535
count: 1
35413536
path: libraries/classes/Controllers/Database/Structure/ReplacePrefixController.php
35423537

3543-
-
3544-
message: "#^Casting to string something that's already string\\.$#"
3545-
count: 1
3546-
path: libraries/classes/Controllers/Database/Structure/ReplacePrefixController.php
3547-
35483538
-
35493539
message: "#^Parameter \\#1 \\$dbname of method PhpMyAdmin\\\\DatabaseInterface\\:\\:selectDb\\(\\) expects PhpMyAdmin\\\\Identifiers\\\\DatabaseName\\|string, mixed given\\.$#"
35503540
count: 1
@@ -11895,11 +11885,6 @@ parameters:
1189511885
count: 1
1189611886
path: libraries/classes/Dbal/DbiMysqli.php
1189711887

11898-
-
11899-
message: "#^Casting to int something that's already int\\.$#"
11900-
count: 1
11901-
path: libraries/classes/Dbal/DbiMysqli.php
11902-
1190311888
-
1190411889
message: "#^Method PhpMyAdmin\\\\Dbal\\\\DbiMysqli\\:\\:affectedRows\\(\\) should return int\\|numeric\\-string but returns int\\|string\\.$#"
1190511890
count: 1
@@ -23085,11 +23070,6 @@ parameters:
2308523070
count: 1
2308623071
path: libraries/classes/Sanitize.php
2308723072

23088-
-
23089-
message: "#^Casting to array something that's already array\\.$#"
23090-
count: 4
23091-
path: libraries/classes/Sanitize.php
23092-
2309323073
-
2309423074
message: "#^Construct empty\\(\\) is not allowed\\. Use more strict comparison\\.$#"
2309523075
count: 2

psalm-baseline.xml

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,6 @@
806806
<code><![CDATA[(string) $GLOBALS['cfg']['ForeignKeyDropdownOrder'][0]]]></code>
807807
<code><![CDATA[(string) $GLOBALS['cfg']['ForeignKeyDropdownOrder'][1]]]></code>
808808
<code><![CDATA[(string) $GLOBALS['cfg']['ForeignKeyDropdownOrder'][1]]]></code>
809-
<code>(string) $table[1]</code>
810809
</RedundantCast>
811810
<RedundantCondition>
812811
<code><![CDATA[is_array($GLOBALS['cfg']['ForeignKeyDropdownOrder'])]]></code>
@@ -1599,9 +1598,6 @@
15991598
<PossiblyUnusedMethod>
16001599
<code>__construct</code>
16011600
</PossiblyUnusedMethod>
1602-
<RedundantCast>
1603-
<code>(string) $fromPrefix</code>
1604-
</RedundantCast>
16051601
</file>
16061602
<file src="libraries/classes/Controllers/Database/Structure/ShowCreateController.php">
16071603
<MixedArgument>
@@ -5428,9 +5424,6 @@
54285424
<PossiblyNullOperand>
54295425
<code>$errorMessage</code>
54305426
</PossiblyNullOperand>
5431-
<RedundantCast>
5432-
<code><![CDATA[(int) $mysqli->protocol_version]]></code>
5433-
</RedundantCast>
54345427
</file>
54355428
<file src="libraries/classes/Dbal/MysqliResult.php">
54365429
<InvalidReturnStatement>
@@ -10890,12 +10883,6 @@
1089010883
<code>$found[0]</code>
1089110884
<code>$found[0]</code>
1089210885
</MixedReturnStatement>
10893-
<RedundantCast>
10894-
<code>(array) $_COOKIE</code>
10895-
<code>(array) $_GET</code>
10896-
<code>(array) $_POST</code>
10897-
<code>(array) $_REQUEST</code>
10898-
</RedundantCast>
1089910886
<RedundantCondition>
1090010887
<code><![CDATA[$GLOBALS['config'] !== null]]></code>
1090110888
</RedundantCondition>

0 commit comments

Comments
 (0)