|
2 | 2 |
|
3 | 3 | namespace PHPStan\Command;
|
4 | 4 |
|
| 5 | +use OndraM\CiDetector\CiDetector; |
5 | 6 | use PHPStan\Command\ErrorFormatter\BaselineNeonErrorFormatter;
|
6 | 7 | use PHPStan\Command\ErrorFormatter\ErrorFormatter;
|
7 | 8 | use PHPStan\Command\Symfony\SymfonyOutput;
|
@@ -51,7 +52,7 @@ protected function configure(): void
|
51 | 52 | new InputOption(ErrorsConsoleStyle::OPTION_NO_PROGRESS, null, InputOption::VALUE_NONE, 'Do not show progress bar, only results'),
|
52 | 53 | new InputOption('debug', null, InputOption::VALUE_NONE, 'Show debug information - which file is analysed, do not catch internal errors'),
|
53 | 54 | new InputOption('autoload-file', 'a', InputOption::VALUE_REQUIRED, 'Project\'s additional autoload file path'),
|
54 |
| - new InputOption('error-format', null, InputOption::VALUE_REQUIRED, 'Format in which to print the result of the analysis', 'table'), |
| 55 | + new InputOption('error-format', null, InputOption::VALUE_REQUIRED, 'Format in which to print the result of the analysis', null), |
55 | 56 | new InputOption('generate-baseline', null, InputOption::VALUE_OPTIONAL, 'Path to a file where the baseline should be saved', false),
|
56 | 57 | new InputOption('memory-limit', null, InputOption::VALUE_REQUIRED, 'Memory limit for analysis'),
|
57 | 58 | new InputOption('xdebug', null, InputOption::VALUE_NONE, 'Allow running with XDebug for debugging purposes'),
|
@@ -136,6 +137,20 @@ protected function execute(InputInterface $input, OutputInterface $output): int
|
136 | 137 | throw new \PHPStan\ShouldNotHappenException();
|
137 | 138 | }
|
138 | 139 |
|
| 140 | + if ($errorFormat === null) { |
| 141 | + $errorFormat = 'table'; |
| 142 | + $ciDetector = new CiDetector(); |
| 143 | + |
| 144 | + try { |
| 145 | + $ci = $ciDetector->detect(); |
| 146 | + if ($ci->getCiName() === CiDetector::CI_GITHUB_ACTIONS) { |
| 147 | + $errorFormat = 'github'; |
| 148 | + } |
| 149 | + } catch (\OndraM\CiDetector\Exception\CiNotDetectedException $e) { |
| 150 | + // pass |
| 151 | + } |
| 152 | + } |
| 153 | + |
139 | 154 | $container = $inceptionResult->getContainer();
|
140 | 155 | $errorFormatterServiceName = sprintf('errorFormatter.%s', $errorFormat);
|
141 | 156 | if (!$container->hasService($errorFormatterServiceName)) {
|
|
0 commit comments