Skip to content

Commit fed28bc

Browse files
committed
Fix
1 parent b4945ec commit fed28bc

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/Command/CommandHelper.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
use PHPStan\DependencyInjection\LoaderFactory;
2424
use PHPStan\DependencyInjection\NeonAdapter;
2525
use PHPStan\ExtensionInstaller\GeneratedConfig;
26+
use PHPStan\File\CouldNotReadFileException;
2627
use PHPStan\File\FileFinder;
2728
use PHPStan\File\FileHelper;
2829
use PHPStan\File\FileReader;
@@ -316,10 +317,16 @@ public static function begin(
316317

317318
$memoryLimitFile = $container->getParameter('memoryLimitFile');
318319
if ($manageMemoryLimitFile && is_file($memoryLimitFile)) {
319-
$memoryLimitFileContents = FileReader::read($memoryLimitFile);
320320
$errorOutput->writeLineFormatted('PHPStan crashed in the previous run probably because of excessive memory consumption.');
321-
$errorOutput->writeLineFormatted(sprintf('It consumed around %s of memory.', $memoryLimitFileContents));
322-
$errorOutput->writeLineFormatted('');
321+
322+
try {
323+
$memoryLimitFileContents = FileReader::read($memoryLimitFile);
324+
$errorOutput->writeLineFormatted(sprintf('It consumed around %s of memory.', $memoryLimitFileContents));
325+
$errorOutput->writeLineFormatted('');
326+
} catch (CouldNotReadFileException $e) {
327+
// pass
328+
}
329+
323330
$errorOutput->writeLineFormatted('');
324331
$errorOutput->writeLineFormatted('To avoid this issue, allow to use more memory with the --memory-limit option.');
325332
@unlink($memoryLimitFile);

0 commit comments

Comments
 (0)