mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-27 12:38:44 +02:00
N°8910 - Upgrade Symfony packages (#811)
This commit is contained in:
@@ -403,6 +403,15 @@ class Application implements ResetInterface
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
CompletionInput::TYPE_OPTION_VALUE === $input->getCompletionType()
|
||||
&& ($definition = $this->getDefinition())->hasOption($input->getCompletionName())
|
||||
) {
|
||||
$definition->getOption($input->getCompletionName())->complete($input, $suggestions);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -723,15 +732,14 @@ class Application implements ResetInterface
|
||||
$message = \sprintf('Command "%s" is not defined.', $name);
|
||||
|
||||
if ($alternatives = $this->findAlternatives($name, $allCommands)) {
|
||||
// remove hidden commands
|
||||
$alternatives = array_filter($alternatives, fn ($name) => !$this->get($name)->isHidden());
|
||||
$wantHelps = $this->wantHelps;
|
||||
$this->wantHelps = false;
|
||||
|
||||
if (1 == \count($alternatives)) {
|
||||
$message .= "\n\nDid you mean this?\n ";
|
||||
} else {
|
||||
$message .= "\n\nDid you mean one of these?\n ";
|
||||
// remove hidden commands
|
||||
if ($alternatives = array_filter($alternatives, fn ($name) => !$this->get($name)->isHidden())) {
|
||||
$message .= \sprintf("\n\nDid you mean %s?\n %s", 1 === \count($alternatives) ? 'this' : 'one of these', implode("\n ", $alternatives));
|
||||
}
|
||||
$message .= implode("\n ", $alternatives);
|
||||
$this->wantHelps = $wantHelps;
|
||||
}
|
||||
|
||||
throw new CommandNotFoundException($message, array_values($alternatives));
|
||||
@@ -779,9 +787,9 @@ class Application implements ResetInterface
|
||||
}
|
||||
}
|
||||
|
||||
$command = $this->get(reset($commands));
|
||||
$command = $commands ? $this->get(reset($commands)) : null;
|
||||
|
||||
if ($command->isHidden()) {
|
||||
if (!$command || $command->isHidden()) {
|
||||
throw new CommandNotFoundException(\sprintf('The command "%s" does not exist.', $name));
|
||||
}
|
||||
|
||||
@@ -1012,19 +1020,15 @@ class Application implements ResetInterface
|
||||
}
|
||||
}
|
||||
|
||||
$registeredSignals = false;
|
||||
$commandSignals = $command instanceof SignalableCommandInterface ? $command->getSubscribedSignals() : [];
|
||||
if ($commandSignals || $this->dispatcher && $this->signalsToDispatchEvent) {
|
||||
if (!$this->signalRegistry) {
|
||||
throw new RuntimeException('Unable to subscribe to signal events. Make sure that the "pcntl" extension is installed and that "pcntl_*" functions are not disabled by your php.ini\'s "disable_functions" directive.');
|
||||
}
|
||||
|
||||
if (Terminal::hasSttyAvailable()) {
|
||||
$sttyMode = shell_exec('stty -g');
|
||||
|
||||
foreach ([\SIGINT, \SIGTERM] as $signal) {
|
||||
$this->signalRegistry->register($signal, static fn () => shell_exec('stty '.$sttyMode));
|
||||
}
|
||||
}
|
||||
$registeredSignals = true;
|
||||
$this->getSignalRegistry()->pushCurrentHandlers();
|
||||
|
||||
if ($this->dispatcher) {
|
||||
// We register application signals, so that we can dispatch the event
|
||||
@@ -1075,7 +1079,13 @@ class Application implements ResetInterface
|
||||
}
|
||||
|
||||
if (null === $this->dispatcher) {
|
||||
return $command->run($input, $output);
|
||||
try {
|
||||
return $command->run($input, $output);
|
||||
} finally {
|
||||
if ($registeredSignals) {
|
||||
$this->getSignalRegistry()->popPreviousHandlers();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// bind before the console.command event, so the listeners have access to input options/arguments
|
||||
@@ -1105,6 +1115,10 @@ class Application implements ResetInterface
|
||||
if (0 === $exitCode = $event->getExitCode()) {
|
||||
$e = null;
|
||||
}
|
||||
} finally {
|
||||
if ($registeredSignals) {
|
||||
$this->getSignalRegistry()->popPreviousHandlers();
|
||||
}
|
||||
}
|
||||
|
||||
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
|
||||
|
||||
Reference in New Issue
Block a user