Skip to content

Commit

Permalink
Show internal errors that occured when generating a baseline
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jan 4, 2024
1 parent 78ea9a6 commit c997ea9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/Command/AnalyseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
use Throwable;
use function array_intersect;
use function array_map;
use function array_unique;
use function array_values;
use function count;
use function dirname;
use function filesize;
Expand Down Expand Up @@ -323,7 +325,17 @@ protected function execute(InputInterface $input, OutputInterface $output): int
return $inceptionResult->handleReturn(1, $analysisResult->getPeakMemoryUsageBytes());
}
if ($analysisResult->hasInternalErrors()) {
$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.');
$internalErrors = array_values(array_unique($analysisResult->getInternalErrors()));

foreach ($internalErrors as $internalError) {
$inceptionResult->getStdOutput()->writeLineFormatted($internalError);
$inceptionResult->getStdOutput()->writeLineFormatted('');
}

$inceptionResult->getStdOutput()->getStyle()->error(sprintf(
'%s occurred. Baseline could not be generated.',
count($internalErrors) === 1 ? 'An internal error' : 'Internal errors',
));

return $inceptionResult->handleReturn(1, $analysisResult->getPeakMemoryUsageBytes());
}
Expand Down

0 comments on commit c997ea9

Please sign in to comment.