Skip to content

Commit

Permalink
Merge pull request phpmyadmin#18083 from kamil-tekiela/Fix-PHP-8-issues
Browse files Browse the repository at this point in the history
Fix PHP 8 issues due to changed internal functions
  • Loading branch information
MauricioFauth authored Feb 13, 2023
2 parents 3716f94 + 5c5eeb9 commit ef941c2
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 36 deletions.
2 changes: 1 addition & 1 deletion libraries/classes/InsertEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ private function getSpecialCharsAndBackupFieldForInsertingMode(
$specialChars = bin2hex($column['Default']);
} elseif (substr($trueType, -4) === 'text') {
$textDefault = substr($column['Default'], 1, -1);
$specialChars = stripcslashes($textDefault !== false ? $textDefault : $column['Default']);
$specialChars = stripcslashes($textDefault !== '' ? $textDefault : $column['Default']);
} else {
$specialChars = htmlspecialchars($column['Default']);
}
Expand Down
3 changes: 1 addition & 2 deletions libraries/classes/ZipExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,6 @@ public function createFile($data, $name, $time = 0)

$data = $newData;
} elseif (is_array($data) && is_array($name) && count($data) === count($name)) {
/** @var array $data */
$data = array_combine($name, $data);
} else {
return false;
Expand Down Expand Up @@ -269,7 +268,7 @@ public function createFile($data, $name, $time = 0)
$uncLen = strlen($dump);
$crc = crc32($dump);
$zdata = (string) gzcompress($dump);
$zdata = substr((string) substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$zdata = substr(substr($zdata, 0, strlen($zdata) - 4), 2); // fix crc bug
$cLen = strlen($zdata);
$fr = "\x50\x4b\x03\x04"
. "\x14\x00" // ver needed to extract
Expand Down
20 changes: 0 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -4895,11 +4895,6 @@ parameters:
count: 1
path: libraries/classes/IndexColumn.php

-
message: "#^Else branch is unreachable because ternary operator condition is always true\\.$#"
count: 1
path: libraries/classes/InsertEdit.php

-
message: "#^Method PhpMyAdmin\\\\InsertEdit\\:\\:analyzeTableColumnsArray\\(\\) has parameter \\$column with no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -5245,11 +5240,6 @@ parameters:
count: 1
path: libraries/classes/InsertEdit.php

-
message: "#^Strict comparison using \\!\\=\\= between string and false will always evaluate to true\\.$#"
count: 1
path: libraries/classes/InsertEdit.php

-
message: "#^Method PhpMyAdmin\\\\InternalRelations\\:\\:getInformationSchema\\(\\) return type has no value type specified in iterable type array\\.$#"
count: 1
Expand Down Expand Up @@ -9165,11 +9155,6 @@ parameters:
count: 1
path: libraries/classes/VersionInformation.php

-
message: "#^Casting to string something that's already string\\.$#"
count: 1
path: libraries/classes/ZipExtension.php

-
message: "#^Method PhpMyAdmin\\\\ZipExtension\\:\\:createFile\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#"
count: 1
Expand All @@ -9190,11 +9175,6 @@ parameters:
count: 1
path: libraries/classes/ZipExtension.php

-
message: "#^PHPDoc tag @var for variable \\$data has no value type specified in iterable type array\\.$#"
count: 1
path: libraries/classes/ZipExtension.php

-
message: "#^Call to function method_exists\\(\\) with 'PHPUnit\\\\\\\\Framework\\\\\\\\TestCase' and 'assertFileDoesNotEx…' will always evaluate to true\\.$#"
count: 1
Expand Down
14 changes: 1 addition & 13 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9271,9 +9271,6 @@
</PossiblyUnusedMethod>
</file>
<file src="libraries/classes/InsertEdit.php">
<DocblockTypeContradiction>
<code>$column['Default']</code>
</DocblockTypeContradiction>
<InvalidArgument>
<code>$urlParams</code>
</InvalidArgument>
Expand Down Expand Up @@ -9364,7 +9361,7 @@
<code>$specialChars</code>
<code>$specialChars</code>
<code>$specialCharsEncoded</code>
<code>$textDefault !== false ? $textDefault : $column['Default']</code>
<code>$textDefault !== '' ? $textDefault : $column['Default']</code>
<code>$transformationPlugin-&gt;getScripts()</code>
<code>$transformation[$type . '_options'] ?? ''</code>
<code>$trueType</code>
Expand Down Expand Up @@ -9515,9 +9512,6 @@
<RedundantCast>
<code>(int) $GLOBALS['cfg']['InsertRows']</code>
</RedundantCast>
<RedundantConditionGivenDocblockType>
<code>$textDefault !== false</code>
</RedundantConditionGivenDocblockType>
</file>
<file src="libraries/classes/IpAllowDeny.php">
<InvalidArrayOffset>
Expand Down Expand Up @@ -16301,12 +16295,6 @@
<PossiblyUnusedParam>
<code>$time</code>
</PossiblyUnusedParam>
<RedundantCastGivenDocblockType>
<code>(string) substr($zdata, 0, strlen($zdata) - 4)</code>
</RedundantCastGivenDocblockType>
<UnnecessaryVarAnnotation>
<code>array</code>
</UnnecessaryVarAnnotation>
</file>
<file src="libraries/config.default.php">
<UnusedVariable>
Expand Down

0 comments on commit ef941c2

Please sign in to comment.