function CommandDataCollector::collect
Overrides DataCollectorInterface::collect
File
-
vendor/
symfony/ console/ DataCollector/ CommandDataCollector.php, line 30
Class
- CommandDataCollector
- @internal
Namespace
Symfony\Component\Console\DataCollectorCode
public function collect(Request $request, Response $response, ?\Throwable $exception = null) : void {
if (!$request instanceof CliRequest) {
return;
}
$command = $request->command;
$application = $command->getApplication();
$this->data = [
'command' => $this->cloneVar($command->command),
'exit_code' => $command->exitCode,
'interrupted_by_signal' => $command->interruptedBySignal,
'duration' => $command->duration,
'max_memory_usage' => $command->maxMemoryUsage,
'verbosity_level' => match ($command->output
->getVerbosity()) { OutputInterface::VERBOSITY_QUIET => 'quiet',
OutputInterface::VERBOSITY_NORMAL => 'normal',
OutputInterface::VERBOSITY_VERBOSE => 'verbose',
OutputInterface::VERBOSITY_VERY_VERBOSE => 'very verbose',
OutputInterface::VERBOSITY_DEBUG => 'debug',
},
'interactive' => $command->isInteractive,
'validate_input' => !$command->ignoreValidation,
'enabled' => $command->isEnabled(),
'visible' => !$command->isHidden(),
'input' => $this->cloneVar($command->input),
'output' => $this->cloneVar($command->output),
'interactive_inputs' => array_map($this->cloneVar(...), $command->interactiveInputs),
'signalable' => $command->getSubscribedSignals(),
'handled_signals' => $command->handledSignals,
'helper_set' => array_map($this->cloneVar(...), iterator_to_array($command->getHelperSet())),
];
$baseDefinition = $application->getDefinition();
foreach ($command->arguments as $argName => $argValue) {
if ($baseDefinition->hasArgument($argName)) {
$this->data['application_inputs'][$argName] = $this->cloneVar($argValue);
}
else {
$this->data['arguments'][$argName] = $this->cloneVar($argValue);
}
}
foreach ($command->options as $optName => $optValue) {
if ($baseDefinition->hasOption($optName)) {
$this->data['application_inputs']['--' . $optName] = $this->cloneVar($optValue);
}
else {
$this->data['options'][$optName] = $this->cloneVar($optValue);
}
}
}