1111use Symfony \Component \Console \Input \InputInterface ;
1212use Symfony \Component \Console \Output \OutputInterface ;
1313use Throwable ;
14+ use Webmozart \Assert \Assert ;
1415
1516use 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