Skip to content

Commit

Permalink
Remove 15 years old (and now useless) function exists check on file_g…
Browse files Browse the repository at this point in the history
…et_contents

Introduced by: d3f335a
And moved afterwards by: f49b5d2

Now useless, the function always exists and it was the only place where the existence was checked

Signed-off-by: William Desportes <williamdes@wdes.fr>
  • Loading branch information
williamdes committed May 20, 2021
1 parent cfbcf40 commit 7852d1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 27 deletions.
19 changes: 3 additions & 16 deletions libraries/classes/File.php
Expand Up @@ -14,7 +14,6 @@
use function fclose;
use function feof;
use function file_get_contents;
use function filesize;
use function fopen;
use function fread;
use function function_exists;
Expand Down Expand Up @@ -191,7 +190,7 @@ public function setName(?string $name): void
/**
* Gets file content
*
* @return string|false|null the binary file content, or false if no content
* @return string|false the binary file content, or false if no content
*
* @access public
*/
Expand All @@ -209,19 +208,7 @@ public function getRawContent()
return false;
}

if (function_exists('file_get_contents')) {
$this->content = file_get_contents((string) $this->getName());

return $this->content;
}

$size = filesize((string) $this->getName());

if ($size) {
$handle = fopen((string) $this->getName(), 'rb');
$this->content = fread($handle, $size);
fclose($handle);
}
$this->content = file_get_contents((string) $this->getName());

return $this->content;
}
Expand All @@ -237,7 +224,7 @@ public function getRawContent()
public function getContent()
{
$result = $this->getRawContent();
if ($result === false || $result === null) {
if ($result === false) {
return false;
}

Expand Down
12 changes: 1 addition & 11 deletions phpstan-baseline.neon
Expand Up @@ -530,16 +530,6 @@ parameters:
count: 1
path: libraries/classes/File.php

-
message: "#^Parameter \\#1 \\$fp of function fclose expects resource, resource\\|false given\\.$#"
count: 1
path: libraries/classes/File.php

-
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|false given\\.$#"
count: 1
path: libraries/classes/File.php

-
message: "#^Parameter \\#1 \\$fp of function fread expects resource, resource\\|null given\\.$#"
count: 1
Expand All @@ -552,7 +542,7 @@ parameters:

-
message: "#^Property PhpMyAdmin\\\\File\\:\\:\\$content \\(string\\) does not accept string\\|false\\.$#"
count: 2
count: 1
path: libraries/classes/File.php

-
Expand Down

0 comments on commit 7852d1d

Please sign in to comment.