From c997ea9eefb8a57f5e273cff3b3338f423e755b6 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Thu, 4 Jan 2024 22:37:39 +0100 Subject: [PATCH] Show internal errors that occured when generating a baseline --- src/Command/AnalyseCommand.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Command/AnalyseCommand.php b/src/Command/AnalyseCommand.php index 742a92ea1b..915a3041af 100644 --- a/src/Command/AnalyseCommand.php +++ b/src/Command/AnalyseCommand.php @@ -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; @@ -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()); }