Skip to content

Commit

Permalink
Do not rely on registered exception handler when debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Jul 29, 2021
1 parent 0471f87 commit 48ec184
Showing 1 changed file with 30 additions and 11 deletions.
41 changes: 30 additions & 11 deletions src/Command/AnalyseCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,17 +224,36 @@ protected function execute(InputInterface $input, OutputInterface $output): int
throw new \PHPStan\ShouldNotHappenException();
}

$analysisResult = $application->analyse(
$files,
$onlyFiles,
$inceptionResult->getStdOutput(),
$inceptionResult->getErrorOutput(),
$inceptionResult->isDefaultLevelUsed(),
$debug,
$inceptionResult->getProjectConfigFile(),
$inceptionResult->getProjectConfigArray(),
$input
);
try {
$analysisResult = $application->analyse(
$files,
$onlyFiles,
$inceptionResult->getStdOutput(),
$inceptionResult->getErrorOutput(),
$inceptionResult->isDefaultLevelUsed(),
$debug,
$inceptionResult->getProjectConfigFile(),
$inceptionResult->getProjectConfigArray(),
$input
);
} catch (\Throwable $t) {
if ($debug) {
$inceptionResult->getStdOutput()->writeRaw(sprintf(
'Uncaught %s: %s in %s:%d',
get_class($t),
$t->getMessage(),
$t->getFile(),
$t->getLine()
));
$inceptionResult->getStdOutput()->writeLineFormatted('');
$inceptionResult->getStdOutput()->writeRaw($t->getTraceAsString());
$inceptionResult->getStdOutput()->writeLineFormatted('');

return $inceptionResult->handleReturn(1);
}

throw $t;
}

if ($generateBaselineFile !== null) {
if (!$analysisResult->hasErrors()) {
Expand Down

0 comments on commit 48ec184

Please sign in to comment.