Skip to content

Commit

Permalink
Remove unnecessary FileIO from FileReader
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 12, 2022
1 parent 5137bc8 commit 253316f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/File/FileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
namespace PHPStan\File;

use function file_get_contents;
use function is_file;
use function stream_resolve_include_path;

class FileReader
Expand All @@ -13,14 +12,17 @@ public static function read(string $fileName): string
{
$path = $fileName;

if (!is_file($path)) {
$contents = @file_get_contents($path);
if ($contents === false) {
$path = stream_resolve_include_path($fileName);

if ($path === false) {
throw new CouldNotReadFileException($fileName);
}

$contents = @file_get_contents($path);
}
$contents = @file_get_contents($path);

if ($contents === false) {
throw new CouldNotReadFileException($fileName);
}
Expand Down

0 comments on commit 253316f

Please sign in to comment.