From a721c2f4cc098518f4772d3236752a021487463b Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Thu, 20 Jul 2023 10:12:12 +0700 Subject: [PATCH] Revert "Remove unneeded output property on BaseLoggingCommand" This reverts commit 07d9aaa05a3dfe65ca48bd14311fc79ba73b5dde. --- src/Command/BaseLoggingCommand.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Command/BaseLoggingCommand.php b/src/Command/BaseLoggingCommand.php index e2e4f488..cd19c5bc 100644 --- a/src/Command/BaseLoggingCommand.php +++ b/src/Command/BaseLoggingCommand.php @@ -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; @@ -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 * @@ -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']) @@ -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