From 830aff22deca4ada95ef156f0adb8fb1ecdb8199 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sun, 7 Jan 2024 15:55:34 +0300 Subject: [PATCH] 7 --- src/Collector/Console/CommandCollector.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Collector/Console/CommandCollector.php b/src/Collector/Console/CommandCollector.php index 0f14a83b..334a3734 100644 --- a/src/Collector/Console/CommandCollector.php +++ b/src/Collector/Console/CommandCollector.php @@ -59,7 +59,7 @@ public function collect(ConsoleEvent|ConsoleErrorEvent|ConsoleTerminateEvent $ev if ($event instanceof ConsoleTerminateEvent) { $this->commands[$event::class] = [ - 'name' => $command->getName(), + 'name' => $command?->getName() ?? $event->getInput()->getFirstArgument() ?? '', 'command' => $command, 'input' => $this->castInputToString($event->getInput()), 'output' => $this->fetchOutput($event->getOutput()), @@ -68,13 +68,14 @@ public function collect(ConsoleEvent|ConsoleErrorEvent|ConsoleTerminateEvent $ev return; } + $definition = $command?->getDefinition(); $this->commands[$event::class] = [ - 'name' => $command->getName(), + 'name' => $command?->getName() ?? $event->getInput()->getFirstArgument() ?? '', 'command' => $command, 'input' => $this->castInputToString($event->getInput()), 'output' => $this->fetchOutput($event->getOutput()), - 'arguments' => $command->getDefinition()->getArguments(), - 'options' => $command->getDefinition()->getOptions(), + 'arguments' => $definition?->getArguments() ?? [], + 'options' => $definition?->getOptions() ?? [], ]; }