mirror of
https://github.com/linuxserver/Heimdall.git
synced 2025-12-02 21:19:58 +09:00
Update composer dependencies
This commit is contained in:
92
vendor/symfony/console/Application.php
vendored
92
vendor/symfony/console/Application.php
vendored
@@ -44,6 +44,7 @@ use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
use Symfony\Component\Debug\ErrorHandler;
|
||||
use Symfony\Component\Debug\Exception\FatalThrowableError;
|
||||
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy;
|
||||
|
||||
/**
|
||||
* An Application is the container for a collection of commands.
|
||||
@@ -62,7 +63,7 @@ use Symfony\Component\EventDispatcher\EventDispatcherInterface;
|
||||
*/
|
||||
class Application
|
||||
{
|
||||
private $commands = array();
|
||||
private $commands = [];
|
||||
private $wantHelps = false;
|
||||
private $runningCommand;
|
||||
private $name;
|
||||
@@ -90,9 +91,12 @@ class Application
|
||||
$this->defaultCommand = 'list';
|
||||
}
|
||||
|
||||
/**
|
||||
* @final since Symfony 4.3, the type-hint will be updated to the interface from symfony/contracts in 5.0
|
||||
*/
|
||||
public function setDispatcher(EventDispatcherInterface $dispatcher)
|
||||
{
|
||||
$this->dispatcher = $dispatcher;
|
||||
$this->dispatcher = LegacyEventDispatcherProxy::decorate($dispatcher);
|
||||
}
|
||||
|
||||
public function setCommandLoader(CommandLoaderInterface $commandLoader)
|
||||
@@ -193,17 +197,24 @@ class Application
|
||||
*/
|
||||
public function doRun(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (true === $input->hasParameterOption(array('--version', '-V'), true)) {
|
||||
if (true === $input->hasParameterOption(['--version', '-V'], true)) {
|
||||
$output->writeln($this->getLongVersion());
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
try {
|
||||
// Makes ArgvInput::getFirstArgument() able to distinguish an option from an argument.
|
||||
$input->bind($this->getDefinition());
|
||||
} catch (ExceptionInterface $e) {
|
||||
// Errors must be ignored, full binding/validation happens later when the command is known.
|
||||
}
|
||||
|
||||
$name = $this->getCommandName($input);
|
||||
if (true === $input->hasParameterOption(array('--help', '-h'), true)) {
|
||||
if (true === $input->hasParameterOption(['--help', '-h'], true)) {
|
||||
if (!$name) {
|
||||
$name = 'help';
|
||||
$input = new ArrayInput(array('command_name' => $this->defaultCommand));
|
||||
$input = new ArrayInput(['command_name' => $this->defaultCommand]);
|
||||
} else {
|
||||
$this->wantHelps = true;
|
||||
}
|
||||
@@ -214,9 +225,9 @@ class Application
|
||||
$definition = $this->getDefinition();
|
||||
$definition->setArguments(array_merge(
|
||||
$definition->getArguments(),
|
||||
array(
|
||||
[
|
||||
'command' => new InputArgument('command', InputArgument::OPTIONAL, $definition->getArgument('command')->getDescription(), $name),
|
||||
)
|
||||
]
|
||||
));
|
||||
}
|
||||
|
||||
@@ -228,7 +239,7 @@ class Application
|
||||
if (!($e instanceof CommandNotFoundException && !$e instanceof NamespaceNotFoundException) || 1 !== \count($alternatives = $e->getAlternatives()) || !$input->isInteractive()) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
$this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
|
||||
|
||||
if (0 === $event->getExitCode()) {
|
||||
return 0;
|
||||
@@ -247,7 +258,7 @@ class Application
|
||||
if (!$style->confirm(sprintf('Do you want to run "%s" instead? ', $alternative), false)) {
|
||||
if (null !== $this->dispatcher) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
$this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
|
||||
|
||||
return $event->getExitCode();
|
||||
}
|
||||
@@ -535,7 +546,7 @@ class Application
|
||||
*/
|
||||
public function getNamespaces()
|
||||
{
|
||||
$namespaces = array();
|
||||
$namespaces = [];
|
||||
foreach ($this->all() as $command) {
|
||||
$namespaces = array_merge($namespaces, $this->extractAllNamespaces($command->getName()));
|
||||
|
||||
@@ -602,7 +613,16 @@ class Application
|
||||
{
|
||||
$this->init();
|
||||
|
||||
$aliases = array();
|
||||
$aliases = [];
|
||||
|
||||
foreach ($this->commands as $command) {
|
||||
foreach ($command->getAliases() as $alias) {
|
||||
if (!$this->has($alias)) {
|
||||
$this->commands[$alias] = $command;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$allCommands = $this->commandLoader ? array_merge($this->commandLoader->getNames(), array_keys($this->commands)) : array_keys($this->commands);
|
||||
$expr = preg_replace_callback('{([^:]+|)}', function ($matches) { return preg_quote($matches[1]).'[^:]*'; }, $name);
|
||||
$commands = preg_grep('{^'.$expr.'}', $allCommands);
|
||||
@@ -695,7 +715,7 @@ class Application
|
||||
return $commands;
|
||||
}
|
||||
|
||||
$commands = array();
|
||||
$commands = [];
|
||||
foreach ($this->commands as $name => $command) {
|
||||
if ($namespace === $this->extractNamespace($name, substr_count($namespace, ':') + 1)) {
|
||||
$commands[$name] = $command;
|
||||
@@ -722,7 +742,7 @@ class Application
|
||||
*/
|
||||
public static function getAbbreviations($names)
|
||||
{
|
||||
$abbrevs = array();
|
||||
$abbrevs = [];
|
||||
foreach ($names as $name) {
|
||||
for ($len = \strlen($name); $len > 0; --$len) {
|
||||
$abbrev = substr($name, 0, $len);
|
||||
@@ -768,18 +788,18 @@ class Application
|
||||
}
|
||||
|
||||
$width = $this->terminal->getWidth() ? $this->terminal->getWidth() - 1 : PHP_INT_MAX;
|
||||
$lines = array();
|
||||
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : array() as $line) {
|
||||
$lines = [];
|
||||
foreach ('' !== $message ? preg_split('/\r?\n/', $message) : [] as $line) {
|
||||
foreach ($this->splitStringByWidth($line, $width - 4) as $line) {
|
||||
// pre-format lines to get the right string length
|
||||
$lineLength = Helper::strlen($line) + 4;
|
||||
$lines[] = array($line, $lineLength);
|
||||
$lines[] = [$line, $lineLength];
|
||||
|
||||
$len = max($lineLength, $len);
|
||||
}
|
||||
}
|
||||
|
||||
$messages = array();
|
||||
$messages = [];
|
||||
if (!$e instanceof ExceptionInterface || OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
|
||||
$messages[] = sprintf('<comment>%s</comment>', OutputFormatter::escape(sprintf('In %s line %s:', basename($e->getFile()) ?: 'n/a', $e->getLine() ?: 'n/a')));
|
||||
}
|
||||
@@ -801,12 +821,12 @@ class Application
|
||||
// exception related properties
|
||||
$trace = $e->getTrace();
|
||||
|
||||
array_unshift($trace, array(
|
||||
array_unshift($trace, [
|
||||
'function' => '',
|
||||
'file' => $e->getFile() ?: 'n/a',
|
||||
'line' => $e->getLine() ?: 'n/a',
|
||||
'args' => array(),
|
||||
));
|
||||
'args' => [],
|
||||
]);
|
||||
|
||||
for ($i = 0, $count = \count($trace); $i < $count; ++$i) {
|
||||
$class = isset($trace[$i]['class']) ? $trace[$i]['class'] : '';
|
||||
@@ -828,13 +848,13 @@ class Application
|
||||
*/
|
||||
protected function configureIO(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
if (true === $input->hasParameterOption(array('--ansi'), true)) {
|
||||
if (true === $input->hasParameterOption(['--ansi'], true)) {
|
||||
$output->setDecorated(true);
|
||||
} elseif (true === $input->hasParameterOption(array('--no-ansi'), true)) {
|
||||
} elseif (true === $input->hasParameterOption(['--no-ansi'], true)) {
|
||||
$output->setDecorated(false);
|
||||
}
|
||||
|
||||
if (true === $input->hasParameterOption(array('--no-interaction', '-n'), true)) {
|
||||
if (true === $input->hasParameterOption(['--no-interaction', '-n'], true)) {
|
||||
$input->setInteractive(false);
|
||||
} elseif (\function_exists('posix_isatty')) {
|
||||
$inputStream = null;
|
||||
@@ -856,7 +876,7 @@ class Application
|
||||
default: $shellVerbosity = 0; break;
|
||||
}
|
||||
|
||||
if (true === $input->hasParameterOption(array('--quiet', '-q'), true)) {
|
||||
if (true === $input->hasParameterOption(['--quiet', '-q'], true)) {
|
||||
$output->setVerbosity(OutputInterface::VERBOSITY_QUIET);
|
||||
$shellVerbosity = -1;
|
||||
} else {
|
||||
@@ -913,7 +933,7 @@ class Application
|
||||
$e = null;
|
||||
|
||||
try {
|
||||
$this->dispatcher->dispatch(ConsoleEvents::COMMAND, $event);
|
||||
$this->dispatcher->dispatch($event, ConsoleEvents::COMMAND);
|
||||
|
||||
if ($event->commandShouldRun()) {
|
||||
$exitCode = $command->run($input, $output);
|
||||
@@ -922,7 +942,7 @@ class Application
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$event = new ConsoleErrorEvent($input, $output, $e, $command);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::ERROR, $event);
|
||||
$this->dispatcher->dispatch($event, ConsoleEvents::ERROR);
|
||||
$e = $event->getError();
|
||||
|
||||
if (0 === $exitCode = $event->getExitCode()) {
|
||||
@@ -931,7 +951,7 @@ class Application
|
||||
}
|
||||
|
||||
$event = new ConsoleTerminateEvent($command, $input, $output, $exitCode);
|
||||
$this->dispatcher->dispatch(ConsoleEvents::TERMINATE, $event);
|
||||
$this->dispatcher->dispatch($event, ConsoleEvents::TERMINATE);
|
||||
|
||||
if (null !== $e) {
|
||||
throw $e;
|
||||
@@ -957,7 +977,7 @@ class Application
|
||||
*/
|
||||
protected function getDefaultInputDefinition()
|
||||
{
|
||||
return new InputDefinition(array(
|
||||
return new InputDefinition([
|
||||
new InputArgument('command', InputArgument::REQUIRED, 'The command to execute'),
|
||||
|
||||
new InputOption('--help', '-h', InputOption::VALUE_NONE, 'Display this help message'),
|
||||
@@ -967,7 +987,7 @@ class Application
|
||||
new InputOption('--ansi', '', InputOption::VALUE_NONE, 'Force ANSI output'),
|
||||
new InputOption('--no-ansi', '', InputOption::VALUE_NONE, 'Disable ANSI output'),
|
||||
new InputOption('--no-interaction', '-n', InputOption::VALUE_NONE, 'Do not ask any interactive question'),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -977,7 +997,7 @@ class Application
|
||||
*/
|
||||
protected function getDefaultCommands()
|
||||
{
|
||||
return array(new HelpCommand(), new ListCommand());
|
||||
return [new HelpCommand(), new ListCommand()];
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -987,12 +1007,12 @@ class Application
|
||||
*/
|
||||
protected function getDefaultHelperSet()
|
||||
{
|
||||
return new HelperSet(array(
|
||||
return new HelperSet([
|
||||
new FormatterHelper(),
|
||||
new DebugFormatterHelper(),
|
||||
new ProcessHelper(),
|
||||
new QuestionHelper(),
|
||||
));
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1037,9 +1057,9 @@ class Application
|
||||
private function findAlternatives($name, $collection)
|
||||
{
|
||||
$threshold = 1e3;
|
||||
$alternatives = array();
|
||||
$alternatives = [];
|
||||
|
||||
$collectionParts = array();
|
||||
$collectionParts = [];
|
||||
foreach ($collection as $item) {
|
||||
$collectionParts[$item] = explode(':', $item);
|
||||
}
|
||||
@@ -1116,7 +1136,7 @@ class Application
|
||||
}
|
||||
|
||||
$utf8String = mb_convert_encoding($string, 'utf8', $encoding);
|
||||
$lines = array();
|
||||
$lines = [];
|
||||
$line = '';
|
||||
foreach (preg_split('//u', $utf8String) as $char) {
|
||||
// test if $char could be appended to current line
|
||||
@@ -1147,7 +1167,7 @@ class Application
|
||||
{
|
||||
// -1 as third argument is needed to skip the command short name when exploding
|
||||
$parts = explode(':', $name, -1);
|
||||
$namespaces = array();
|
||||
$namespaces = [];
|
||||
|
||||
foreach ($parts as $part) {
|
||||
if (\count($namespaces)) {
|
||||
|
||||
Reference in New Issue
Block a user