diff --git a/src/Command/AnalyseCommand.php b/src/Command/AnalyseCommand.php index e723a32189..d2051503d5 100644 --- a/src/Command/AnalyseCommand.php +++ b/src/Command/AnalyseCommand.php @@ -87,7 +87,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $autoloadFile, $configuration, $level, - $allowXdebug + $allowXdebug, + $this->getApplication() ); } catch (\PHPStan\Command\InceptionNotSuccessfulException $e) { return 1; diff --git a/src/Command/CommandHelper.php b/src/Command/CommandHelper.php index 46861f1246..8662c5d414 100644 --- a/src/Command/CommandHelper.php +++ b/src/Command/CommandHelper.php @@ -14,6 +14,7 @@ use PHPStan\DependencyInjection\NeonAdapter; use PHPStan\File\FileFinder; use PHPStan\File\FileHelper; +use Symfony\Component\Console\Application; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\ConsoleOutputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -36,7 +37,8 @@ public static function begin( ?string $autoloadFile, ?string $projectConfigFile, ?string $level, - bool $allowXdebug + bool $allowXdebug, + Application $application ): InceptionResult { if (!$allowXdebug) { @@ -129,7 +131,7 @@ public static function begin( try { $projectConfig = $loader->load($projectConfigFile, null); } catch (\Nette\InvalidStateException | \Nette\FileNotFoundException $e) { - $errorOutput->writeln($e->getMessage()); + $application->renderException($e); throw new \PHPStan\Command\InceptionNotSuccessfulException(); } $defaultParameters = [ @@ -302,7 +304,8 @@ public static function begin( require_once $file; })($bootstrapFile); } catch (\Throwable $e) { - $errorOutput->writeln($e->getMessage()); + $application->renderException($e); + throw new \PHPStan\Command\InceptionNotSuccessfulException(); } } diff --git a/src/Command/DumpDependenciesCommand.php b/src/Command/DumpDependenciesCommand.php index ef9ce11596..d3815b144f 100644 --- a/src/Command/DumpDependenciesCommand.php +++ b/src/Command/DumpDependenciesCommand.php @@ -61,7 +61,8 @@ protected function execute(InputInterface $input, OutputInterface $output): int $autoloadFile, $configurationFile, '0', // irrelevant but prevents an error when a config file is passed - $allowXdebug + $allowXdebug, + $this->getApplication() ); } catch (\PHPStan\Command\InceptionNotSuccessfulException $e) { return 1;