|
16 | 16 | use PHPStan\DependencyInjection\NeonAdapter; |
17 | 17 | use PHPStan\File\FileFinder; |
18 | 18 | use PHPStan\File\FileHelper; |
| 19 | +use PHPStan\File\FileReader; |
19 | 20 | use Symfony\Component\Console\Input\InputInterface; |
20 | 21 | use Symfony\Component\Console\Output\ConsoleOutputInterface; |
21 | 22 | use Symfony\Component\Console\Output\OutputInterface; |
@@ -109,9 +110,11 @@ public static function begin( |
109 | 110 | throw new \PHPStan\Command\InceptionNotSuccessfulException(); |
110 | 111 | } |
111 | 112 |
|
112 | | - $pathsString = file_get_contents($pathsFile); |
113 | | - if ($pathsString === false) { |
114 | | - throw new \PHPStan\ShouldNotHappenException(); |
| 113 | + try { |
| 114 | + $pathsString = FileReader::read($pathsFile); |
| 115 | + } catch (\PHPStan\File\CouldNotReadFileException $e) { |
| 116 | + $errorOutput->writeLineFormatted($e->getMessage()); |
| 117 | + throw new \PHPStan\Command\InceptionNotSuccessfulException(); |
115 | 118 | } |
116 | 119 |
|
117 | 120 | $paths = array_values(array_filter(explode("\n", $pathsString), static function (string $path): bool { |
@@ -225,10 +228,7 @@ public static function begin( |
225 | 228 |
|
226 | 229 | $memoryLimitFile = $container->getParameter('memoryLimitFile'); |
227 | 230 | if (file_exists($memoryLimitFile)) { |
228 | | - $memoryLimitFileContents = file_get_contents($memoryLimitFile); |
229 | | - if ($memoryLimitFileContents === false) { |
230 | | - throw new \PHPStan\ShouldNotHappenException(); |
231 | | - } |
| 231 | + $memoryLimitFileContents = FileReader::read($memoryLimitFile); |
232 | 232 | $errorOutput->writeLineFormatted('PHPStan crashed in the previous run probably because of excessive memory consumption.'); |
233 | 233 | $errorOutput->writeLineFormatted(sprintf('It consumed around %s of memory.', $memoryLimitFileContents)); |
234 | 234 | $errorOutput->writeLineFormatted(''); |
|
0 commit comments