Skip to content

Commit

Permalink
Revert "Remove unneeded output property on BaseLoggingCommand"
Browse files Browse the repository at this point in the history
This reverts commit 07d9aaa.
  • Loading branch information
samsonasik committed Jul 20, 2023
1 parent 07d9aaa commit a721c2f
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/Command/BaseLoggingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Throwable;
use Webmozart\Assert\Assert;

use function ErrorHeroModule\isExcludedException;

Expand All @@ -25,6 +26,8 @@ abstract class BaseLoggingCommand extends Command

private Logging $logging;

private ?OutputInterface $output = null;

/**
* MUST BE CALLED after __construct(), as service extends this base class may use depedendency injection
*
Expand All @@ -38,16 +41,18 @@ public function init(array $errorHeroModuleConfig, Logging $logging): void

public function run(InputInterface $input, OutputInterface $output): int
{
$this->output = $output;

try {
$this->phpError();
return parent::run($input, $output);
} catch (Throwable $throwable) {
}

return $this->exceptionError($throwable, $output);
return $this->exceptionError($throwable);
}

private function exceptionError(Throwable $throwable, OutputInterface $output): int
private function exceptionError(Throwable $throwable): int
{
if (
isset($this->errorHeroModuleConfig[self::DISPLAY_SETTINGS]['exclude-exceptions'])
Expand All @@ -66,7 +71,8 @@ private function exceptionError(Throwable $throwable, OutputInterface $output):
}

// show default view if display_errors setting = 0.
return $this->showDefaultConsoleView($output);
Assert::isInstanceOf($this->output, OutputInterface::class);
return $this->showDefaultConsoleView($this->output);
}

private function showDefaultConsoleView(OutputInterface $output): int
Expand Down

0 comments on commit a721c2f

Please sign in to comment.