Skip to content

Commit

Permalink
Revert "Decorate CI-detected error formatter with the set one by the …
Browse files Browse the repository at this point in the history
…user, not TableErrorFormatter"

This reverts commit bfe47cb.
  • Loading branch information
ondrejmirtes committed May 24, 2022
1 parent ae348d9 commit 34ad812
Showing 1 changed file with 15 additions and 23 deletions.
38 changes: 15 additions & 23 deletions src/Command/AnalyseCommand.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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()),
);
Expand Down

0 comments on commit 34ad812

Please sign in to comment.