Skip to content

Commit a721c2f

Browse files
committed
Revert "Remove unneeded output property on BaseLoggingCommand"
This reverts commit 07d9aaa.
1 parent 07d9aaa commit a721c2f

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/Command/BaseLoggingCommand.php

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Symfony\Component\Console\Input\InputInterface;
1212
use Symfony\Component\Console\Output\OutputInterface;
1313
use Throwable;
14+
use Webmozart\Assert\Assert;
1415

1516
use function ErrorHeroModule\isExcludedException;
1617

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

2627
private Logging $logging;
2728

29+
private ?OutputInterface $output = null;
30+
2831
/**
2932
* MUST BE CALLED after __construct(), as service extends this base class may use depedendency injection
3033
*
@@ -38,16 +41,18 @@ public function init(array $errorHeroModuleConfig, Logging $logging): void
3841

3942
public function run(InputInterface $input, OutputInterface $output): int
4043
{
44+
$this->output = $output;
45+
4146
try {
4247
$this->phpError();
4348
return parent::run($input, $output);
4449
} catch (Throwable $throwable) {
4550
}
4651

47-
return $this->exceptionError($throwable, $output);
52+
return $this->exceptionError($throwable);
4853
}
4954

50-
private function exceptionError(Throwable $throwable, OutputInterface $output): int
55+
private function exceptionError(Throwable $throwable): int
5156
{
5257
if (
5358
isset($this->errorHeroModuleConfig[self::DISPLAY_SETTINGS]['exclude-exceptions'])
@@ -66,7 +71,8 @@ private function exceptionError(Throwable $throwable, OutputInterface $output):
6671
}
6772

6873
// show default view if display_errors setting = 0.
69-
return $this->showDefaultConsoleView($output);
74+
Assert::isInstanceOf($this->output, OutputInterface::class);
75+
return $this->showDefaultConsoleView($this->output);
7076
}
7177

7278
private function showDefaultConsoleView(OutputInterface $output): int

0 commit comments

Comments
 (0)