Skip to content

Commit

Permalink
FileReader - assert is_file() before reading
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed May 14, 2020
1 parent 710fec9 commit 9fd30bf
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/File/FileReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ class FileReader

public static function read(string $fileName): string
{
if (!is_file($fileName)) {
throw new \PHPStan\File\CouldNotReadFileException($fileName);
}
$contents = @file_get_contents($fileName);
if ($contents === false) {
throw new \PHPStan\File\CouldNotReadFileException($fileName);
Expand Down

0 comments on commit 9fd30bf

Please sign in to comment.