Skip to content

Commit

Permalink
Better application exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
lookyman authored and ondrejmirtes committed Jun 30, 2018
1 parent 8264094 commit bdf954e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 1 addition & 7 deletions bin/phpstan
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

use Composer\XdebugHandler\XdebugHandler;
use PHPStan\Command\AnalyseCommand;
use Symfony\Component\Console\Exception\CommandNotFoundException;

gc_disable(); // performance boost

Expand Down Expand Up @@ -36,10 +35,5 @@ $application = new \Symfony\Component\Console\Application(
'PHPStan - PHP Static Analysis Tool',
$version
);
$application->setCatchExceptions(false);
$application->add(new AnalyseCommand());
try {
$application->run();
} catch (CommandNotFoundException $exception) {
echo $exception->getMessage()."\n";
}
$application->run();
7 changes: 7 additions & 0 deletions src/Command/AnalyseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,13 @@ public function getAliases(): array
return ['analyze'];
}

protected function initialize(InputInterface $input, OutputInterface $output): void
{
if ((bool) $input->getOption('debug')) {
$this->getApplication()->setCatchExceptions(false);
}
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$errOutput = $output instanceof ConsoleOutputInterface ? $output->getErrorOutput() : $output;
Expand Down

0 comments on commit bdf954e

Please sign in to comment.