upgraded dependencies
This commit is contained in:
68
vendor/symfony/console/Input/ArgvInput.php
vendored
68
vendor/symfony/console/Input/ArgvInput.php
vendored
@@ -43,9 +43,6 @@ class ArgvInput extends Input
|
||||
private $tokens;
|
||||
private $parsed;
|
||||
|
||||
/**
|
||||
* @param array|null $argv An array of parameters from the CLI (in the argv format)
|
||||
*/
|
||||
public function __construct(array $argv = null, InputDefinition $definition = null)
|
||||
{
|
||||
$argv = $argv ?? $_SERVER['argv'] ?? [];
|
||||
@@ -71,20 +68,27 @@ class ArgvInput extends Input
|
||||
$parseOptions = true;
|
||||
$this->parsed = $this->tokens;
|
||||
while (null !== $token = array_shift($this->parsed)) {
|
||||
if ($parseOptions && '' == $token) {
|
||||
$this->parseArgument($token);
|
||||
} elseif ($parseOptions && '--' == $token) {
|
||||
$parseOptions = false;
|
||||
} elseif ($parseOptions && str_starts_with($token, '--')) {
|
||||
$this->parseLongOption($token);
|
||||
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
|
||||
$this->parseShortOption($token);
|
||||
} else {
|
||||
$this->parseArgument($token);
|
||||
}
|
||||
$parseOptions = $this->parseToken($token, $parseOptions);
|
||||
}
|
||||
}
|
||||
|
||||
protected function parseToken(string $token, bool $parseOptions): bool
|
||||
{
|
||||
if ($parseOptions && '' == $token) {
|
||||
$this->parseArgument($token);
|
||||
} elseif ($parseOptions && '--' == $token) {
|
||||
return false;
|
||||
} elseif ($parseOptions && str_starts_with($token, '--')) {
|
||||
$this->parseLongOption($token);
|
||||
} elseif ($parseOptions && '-' === $token[0] && '-' !== $token) {
|
||||
$this->parseShortOption($token);
|
||||
} else {
|
||||
$this->parseArgument($token);
|
||||
}
|
||||
|
||||
return $parseOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses a short option.
|
||||
*/
|
||||
@@ -168,11 +172,25 @@ class ArgvInput extends Input
|
||||
// unexpected argument
|
||||
} else {
|
||||
$all = $this->definition->getArguments();
|
||||
if (\count($all)) {
|
||||
throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
|
||||
$symfonyCommandName = null;
|
||||
if (($inputArgument = $all[$key = array_key_first($all)] ?? null) && 'command' === $inputArgument->getName()) {
|
||||
$symfonyCommandName = $this->arguments['command'] ?? null;
|
||||
unset($all[$key]);
|
||||
}
|
||||
|
||||
throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
|
||||
if (\count($all)) {
|
||||
if ($symfonyCommandName) {
|
||||
$message = sprintf('Too many arguments to "%s" command, expected arguments "%s".', $symfonyCommandName, implode('" "', array_keys($all)));
|
||||
} else {
|
||||
$message = sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all)));
|
||||
}
|
||||
} elseif ($symfonyCommandName) {
|
||||
$message = sprintf('No arguments expected for "%s" command, got "%s".', $symfonyCommandName, $token);
|
||||
} else {
|
||||
$message = sprintf('No arguments expected, got "%s".', $token);
|
||||
}
|
||||
|
||||
throw new RuntimeException($message);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -198,7 +216,17 @@ class ArgvInput extends Input
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
|
||||
if (!$this->definition->hasNegation($name)) {
|
||||
throw new RuntimeException(sprintf('The "--%s" option does not exist.', $name));
|
||||
}
|
||||
|
||||
$optionName = $this->definition->negationToName($name);
|
||||
if (null !== $value) {
|
||||
throw new RuntimeException(sprintf('The "--%s" option does not accept a value.', $name));
|
||||
}
|
||||
$this->options[$optionName] = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$option = $this->definition->getOption($name);
|
||||
@@ -273,7 +301,7 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasParameterOption($values, $onlyParams = false)
|
||||
public function hasParameterOption($values, bool $onlyParams = false)
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -298,7 +326,7 @@ class ArgvInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, $onlyParams = false)
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false)
|
||||
{
|
||||
$values = (array) $values;
|
||||
$tokens = $this->tokens;
|
||||
|
Reference in New Issue
Block a user