Skip to content
Permalink
Browse files

bug: #2103 -- throw error if directories are given instead of file (#…

…2605)

* bug: #2103 -- throw error if directories are given instead of file

* use global is_dir
  • Loading branch information
hexmode authored and muglug committed Jan 12, 2020
1 parent 3eebed6 commit fbc2c21c9b2b8a1d5ff77c1727aaf5d139c37499
Showing with 5 additions and 0 deletions.
  1. +5 −0 src/Psalm/Internal/Provider/FileProvider.php
@@ -6,6 +6,7 @@
use function file_put_contents;
use function filemtime;
use function in_array;
use function is_dir;
use function strtolower;

class FileProvider
@@ -39,6 +40,10 @@ public function getContents($file_path, bool $go_to_source = false)
throw new \UnexpectedValueException('File ' . $file_path . ' should exist to get contents');
}

if (is_dir($file_path)) {
throw new \UnexpectedValueException('File ' . $file_path . ' is a directory');
}

return (string)file_get_contents($file_path);
}

0 comments on commit fbc2c21

Please sign in to comment.
You can’t perform that action at this time.