Change return type of detectCompression

Signed-off-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
Kamil Tekiela 2026-02-26 23:08:00 +00:00
parent ceba692247
commit ae203ed56d
3 changed files with 4 additions and 22 deletions

View File

@ -6075,12 +6075,6 @@ parameters:
count: 2
path: src/File.php
-
message: '#^Method PhpMyAdmin\\File\:\:getCompression\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/File.php
-
message: '#^Only booleans are allowed in a negated boolean, resource\|false given\.$#'
identifier: booleanNot.exprNotBoolean
@ -6111,12 +6105,6 @@ parameters:
count: 4
path: src/File.php
-
message: '#^Switch condition type \(string\) does not match case condition false \(false\)\.$#'
identifier: switch.type
count: 1
path: src/File.php
-
message: '''
#^Call to deprecated method getInstance\(\) of class PhpMyAdmin\\Config\:

View File

@ -4121,9 +4121,6 @@
<DeprecatedMethod>
<code><![CDATA[Config::getInstance()]]></code>
</DeprecatedMethod>
<FalsableReturnStatement>
<code><![CDATA[$this->compression ?? $this->detectCompression()]]></code>
</FalsableReturnStatement>
<InvalidArrayAccess>
<code><![CDATA[$_FILES['fields_upload']['error']['multi_edit']]]></code>
</InvalidArrayAccess>
@ -4131,9 +4128,6 @@
<code><![CDATA[$_FILES['fields_upload']['name']['multi_edit']]]></code>
<code><![CDATA[$_FILES['fields_upload']['tmp_name']['multi_edit']]]></code>
</InvalidArrayOffset>
<InvalidFalsableReturnType>
<code><![CDATA[string]]></code>
</InvalidFalsableReturnType>
<InvalidPropertyAssignmentValue>
<code><![CDATA[$this->handle]]></code>
</InvalidPropertyAssignmentValue>

View File

@ -400,13 +400,13 @@ final class File
/**
* Detects what compression the file uses
*
* @return string|false false on error, otherwise string MIME type of
* @return string empty string on error, otherwise string MIME type of
* compression, none for none
*
* @todo move file read part into readChunk() or getChunk()
* @todo add support for compression plugins
*/
private function detectCompression(): string|false
private function detectCompression(): string
{
// suppress warnings from being displayed, but not from being logged
// f.e. any file access outside of open_basedir will issue a warning
@ -417,7 +417,7 @@ final class File
if (! $file) {
$this->errorMessage = Message::error(__('File could not be read!'));
return false;
return '';
}
$this->compression = Util::getCompressionMimeType($file);
@ -484,7 +484,7 @@ final class File
}
switch ($this->getCompression()) {
case false:
case '':
return false;
case 'application/bzip2':