From 34ad8129793880035da55b02c105b212e59b20b3 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Tue, 24 May 2022 17:19:32 +0200 Subject: [PATCH] Revert "Decorate CI-detected error formatter with the set one by the user, not TableErrorFormatter" This reverts commit bfe47cbf5fdd64f9a14f231144224ef34929833f. --- src/Command/AnalyseCommand.php | 38 ++++++++++++++-------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/src/Command/AnalyseCommand.php b/src/Command/AnalyseCommand.php index dbcbc5d6d4..433492a2cc 100644 --- a/src/Command/AnalyseCommand.php +++ b/src/Command/AnalyseCommand.php @@ -7,9 +7,7 @@ use PHPStan\Analyser\ResultCache\ResultCacheClearer; use PHPStan\Command\ErrorFormatter\BaselineNeonErrorFormatter; use PHPStan\Command\ErrorFormatter\ErrorFormatter; -use PHPStan\Command\ErrorFormatter\GithubErrorFormatter; use PHPStan\Command\ErrorFormatter\TableErrorFormatter; -use PHPStan\Command\ErrorFormatter\TeamcityErrorFormatter; use PHPStan\Command\Symfony\SymfonyOutput; use PHPStan\Command\Symfony\SymfonyStyle; use PHPStan\File\CouldNotWriteFileException; @@ -185,6 +183,18 @@ protected function execute(InputInterface $input, OutputInterface $output): int if ($errorFormat === null) { $errorFormat = 'table'; + $ciDetector = new CiDetector(); + + try { + $ci = $ciDetector->detect(); + if ($ci->getCiName() === CiDetector::CI_GITHUB_ACTIONS) { + $errorFormat = 'github'; + } elseif ($ci->getCiName() === CiDetector::CI_TEAMCITY) { + $errorFormat = 'teamcity'; + } + } catch (CiNotDetectedException) { + // pass + } } $container = $inceptionResult->getContainer(); @@ -198,27 +208,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int return 1; } - /** @var ErrorFormatter $errorFormatter */ - $errorFormatter = $container->getService($errorFormatterServiceName); - - $ciDetector = new CiDetector(); - - try { - $ci = $ciDetector->detect(); - if ($ci->getCiName() === CiDetector::CI_GITHUB_ACTIONS) { - $errorFormatter = new GithubErrorFormatter( - $container->getService('simpleRelativePathHelper'), - $errorFormatter, - ); - } elseif ($ci->getCiName() === CiDetector::CI_TEAMCITY) { - $errorFormatter = new TeamcityErrorFormatter( - $container->getService('simpleRelativePathHelper'), - ); - } - } catch (CiNotDetectedException) { - // pass - } - $generateBaselineFile = $inceptionResult->getGenerateBaselineFile(); if ($generateBaselineFile !== null) { $baselineExtension = pathinfo($generateBaselineFile, PATHINFO_EXTENSION); @@ -444,6 +433,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int ); } + /** @var ErrorFormatter $errorFormatter */ + $errorFormatter = $container->getService($errorFormatterServiceName); + return $inceptionResult->handleReturn( $errorFormatter->formatErrors($analysisResult, $inceptionResult->getStdOutput()), );