Skip to content

Commit c997ea9

Browse files
committed
Show internal errors that occured when generating a baseline
1 parent 78ea9a6 commit c997ea9

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

Diff for: src/Command/AnalyseCommand.php

+13-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
use Throwable;
3030
use function array_intersect;
3131
use function array_map;
32+
use function array_unique;
33+
use function array_values;
3234
use function count;
3335
use function dirname;
3436
use function filesize;
@@ -323,7 +325,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
323325
return $inceptionResult->handleReturn(1, $analysisResult->getPeakMemoryUsageBytes());
324326
}
325327
if ($analysisResult->hasInternalErrors()) {
326-
$inceptionResult->getStdOutput()->getStyle()->error('An internal error occurred. Baseline could not be generated. Re-run PHPStan without --generate-baseline to see what\'s going on.');
328+
$internalErrors = array_values(array_unique($analysisResult->getInternalErrors()));
329+
330+
foreach ($internalErrors as $internalError) {
331+
$inceptionResult->getStdOutput()->writeLineFormatted($internalError);
332+
$inceptionResult->getStdOutput()->writeLineFormatted('');
333+
}
334+
335+
$inceptionResult->getStdOutput()->getStyle()->error(sprintf(
336+
'%s occurred. Baseline could not be generated.',
337+
count($internalErrors) === 1 ? 'An internal error' : 'Internal errors',
338+
));
327339

328340
return $inceptionResult->handleReturn(1, $analysisResult->getPeakMemoryUsageBytes());
329341
}

0 commit comments

Comments
 (0)