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;
|
||||
|
13
vendor/symfony/console/Input/ArrayInput.php
vendored
13
vendor/symfony/console/Input/ArrayInput.php
vendored
@@ -53,7 +53,7 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasParameterOption($values, $onlyParams = false)
|
||||
public function hasParameterOption($values, bool $onlyParams = false)
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -77,7 +77,7 @@ class ArrayInput extends Input
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, $onlyParams = false)
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false)
|
||||
{
|
||||
$values = (array) $values;
|
||||
|
||||
@@ -166,7 +166,14 @@ class ArrayInput extends Input
|
||||
private function addLongOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
|
||||
if (!$this->definition->hasNegation($name)) {
|
||||
throw new InvalidOptionException(sprintf('The "--%s" option does not exist.', $name));
|
||||
}
|
||||
|
||||
$optionName = $this->definition->negationToName($name);
|
||||
$this->options[$optionName] = false;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$option = $this->definition->getOption($name);
|
||||
|
42
vendor/symfony/console/Input/Input.php
vendored
42
vendor/symfony/console/Input/Input.php
vendored
@@ -88,9 +88,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setInteractive($interactive)
|
||||
public function setInteractive(bool $interactive)
|
||||
{
|
||||
$this->interactive = (bool) $interactive;
|
||||
$this->interactive = $interactive;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -104,9 +104,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getArgument($name)
|
||||
public function getArgument(string $name)
|
||||
{
|
||||
if (!$this->definition->hasArgument((string) $name)) {
|
||||
if (!$this->definition->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
}
|
||||
|
||||
@@ -116,9 +116,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setArgument($name, $value)
|
||||
public function setArgument(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasArgument((string) $name)) {
|
||||
if (!$this->definition->hasArgument($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
|
||||
}
|
||||
|
||||
@@ -128,9 +128,9 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasArgument($name)
|
||||
public function hasArgument(string $name)
|
||||
{
|
||||
return $this->definition->hasArgument((string) $name);
|
||||
return $this->definition->hasArgument($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -144,8 +144,16 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getOption($name)
|
||||
public function getOption(string $name)
|
||||
{
|
||||
if ($this->definition->hasNegation($name)) {
|
||||
if (null === $value = $this->getOption($this->definition->negationToName($name))) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
return !$value;
|
||||
}
|
||||
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
|
||||
}
|
||||
@@ -156,9 +164,13 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setOption($name, $value)
|
||||
public function setOption(string $name, $value)
|
||||
{
|
||||
if (!$this->definition->hasOption($name)) {
|
||||
if ($this->definition->hasNegation($name)) {
|
||||
$this->options[$this->definition->negationToName($name)] = !$value;
|
||||
|
||||
return;
|
||||
} elseif (!$this->definition->hasOption($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "%s" option does not exist.', $name));
|
||||
}
|
||||
|
||||
@@ -168,19 +180,17 @@ abstract class Input implements InputInterface, StreamableInputInterface
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasOption($name)
|
||||
public function hasOption(string $name)
|
||||
{
|
||||
return $this->definition->hasOption($name);
|
||||
return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a token through escapeshellarg if it contains unsafe chars.
|
||||
*
|
||||
* @param string $token
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function escapeToken($token)
|
||||
public function escapeToken(string $token)
|
||||
{
|
||||
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
|
||||
}
|
||||
|
@@ -56,7 +56,7 @@ class InputArgument
|
||||
/**
|
||||
* Returns the argument name.
|
||||
*
|
||||
* @return string The argument name
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@@ -120,7 +120,7 @@ class InputArgument
|
||||
/**
|
||||
* Returns the description text.
|
||||
*
|
||||
* @return string The description text
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
|
112
vendor/symfony/console/Input/InputDefinition.php
vendored
112
vendor/symfony/console/Input/InputDefinition.php
vendored
@@ -30,9 +30,10 @@ class InputDefinition
|
||||
{
|
||||
private $arguments;
|
||||
private $requiredCount;
|
||||
private $hasAnArrayArgument = false;
|
||||
private $hasOptional;
|
||||
private $lastArrayArgument;
|
||||
private $lastOptionalArgument;
|
||||
private $options;
|
||||
private $negations;
|
||||
private $shortcuts;
|
||||
|
||||
/**
|
||||
@@ -67,12 +68,12 @@ class InputDefinition
|
||||
*
|
||||
* @param InputArgument[] $arguments An array of InputArgument objects
|
||||
*/
|
||||
public function setArguments($arguments = [])
|
||||
public function setArguments(array $arguments = [])
|
||||
{
|
||||
$this->arguments = [];
|
||||
$this->requiredCount = 0;
|
||||
$this->hasOptional = false;
|
||||
$this->hasAnArrayArgument = false;
|
||||
$this->lastOptionalArgument = null;
|
||||
$this->lastArrayArgument = null;
|
||||
$this->addArguments($arguments);
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ class InputDefinition
|
||||
*
|
||||
* @param InputArgument[] $arguments An array of InputArgument objects
|
||||
*/
|
||||
public function addArguments($arguments = [])
|
||||
public function addArguments(?array $arguments = [])
|
||||
{
|
||||
if (null !== $arguments) {
|
||||
foreach ($arguments as $argument) {
|
||||
@@ -99,22 +100,22 @@ class InputDefinition
|
||||
throw new LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
|
||||
}
|
||||
|
||||
if ($this->hasAnArrayArgument) {
|
||||
throw new LogicException('Cannot add an argument after an array argument.');
|
||||
if (null !== $this->lastArrayArgument) {
|
||||
throw new LogicException(sprintf('Cannot add a required argument "%s" after an array argument "%s".', $argument->getName(), $this->lastArrayArgument->getName()));
|
||||
}
|
||||
|
||||
if ($argument->isRequired() && $this->hasOptional) {
|
||||
throw new LogicException('Cannot add a required argument after an optional one.');
|
||||
if ($argument->isRequired() && null !== $this->lastOptionalArgument) {
|
||||
throw new LogicException(sprintf('Cannot add a required argument "%s" after an optional one "%s".', $argument->getName(), $this->lastOptionalArgument->getName()));
|
||||
}
|
||||
|
||||
if ($argument->isArray()) {
|
||||
$this->hasAnArrayArgument = true;
|
||||
$this->lastArrayArgument = $argument;
|
||||
}
|
||||
|
||||
if ($argument->isRequired()) {
|
||||
++$this->requiredCount;
|
||||
} else {
|
||||
$this->hasOptional = true;
|
||||
$this->lastOptionalArgument = $argument;
|
||||
}
|
||||
|
||||
$this->arguments[$argument->getName()] = $argument;
|
||||
@@ -125,7 +126,7 @@ class InputDefinition
|
||||
*
|
||||
* @param string|int $name The InputArgument name or position
|
||||
*
|
||||
* @return InputArgument An InputArgument object
|
||||
* @return InputArgument
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
@@ -145,7 +146,7 @@ class InputDefinition
|
||||
*
|
||||
* @param string|int $name The InputArgument name or position
|
||||
*
|
||||
* @return bool true if the InputArgument object exists, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasArgument($name)
|
||||
{
|
||||
@@ -157,7 +158,7 @@ class InputDefinition
|
||||
/**
|
||||
* Gets the array of InputArgument objects.
|
||||
*
|
||||
* @return InputArgument[] An array of InputArgument objects
|
||||
* @return InputArgument[]
|
||||
*/
|
||||
public function getArguments()
|
||||
{
|
||||
@@ -167,17 +168,17 @@ class InputDefinition
|
||||
/**
|
||||
* Returns the number of InputArguments.
|
||||
*
|
||||
* @return int The number of InputArguments
|
||||
* @return int
|
||||
*/
|
||||
public function getArgumentCount()
|
||||
{
|
||||
return $this->hasAnArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
|
||||
return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of required InputArguments.
|
||||
*
|
||||
* @return int The number of required InputArguments
|
||||
* @return int
|
||||
*/
|
||||
public function getArgumentRequiredCount()
|
||||
{
|
||||
@@ -202,10 +203,11 @@ class InputDefinition
|
||||
*
|
||||
* @param InputOption[] $options An array of InputOption objects
|
||||
*/
|
||||
public function setOptions($options = [])
|
||||
public function setOptions(array $options = [])
|
||||
{
|
||||
$this->options = [];
|
||||
$this->shortcuts = [];
|
||||
$this->negations = [];
|
||||
$this->addOptions($options);
|
||||
}
|
||||
|
||||
@@ -214,7 +216,7 @@ class InputDefinition
|
||||
*
|
||||
* @param InputOption[] $options An array of InputOption objects
|
||||
*/
|
||||
public function addOptions($options = [])
|
||||
public function addOptions(array $options = [])
|
||||
{
|
||||
foreach ($options as $option) {
|
||||
$this->addOption($option);
|
||||
@@ -229,6 +231,9 @@ class InputDefinition
|
||||
if (isset($this->options[$option->getName()]) && !$option->equals($this->options[$option->getName()])) {
|
||||
throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
|
||||
}
|
||||
if (isset($this->negations[$option->getName()])) {
|
||||
throw new LogicException(sprintf('An option named "%s" already exists.', $option->getName()));
|
||||
}
|
||||
|
||||
if ($option->getShortcut()) {
|
||||
foreach (explode('|', $option->getShortcut()) as $shortcut) {
|
||||
@@ -244,18 +249,24 @@ class InputDefinition
|
||||
$this->shortcuts[$shortcut] = $option->getName();
|
||||
}
|
||||
}
|
||||
|
||||
if ($option->isNegatable()) {
|
||||
$negatedName = 'no-'.$option->getName();
|
||||
if (isset($this->options[$negatedName])) {
|
||||
throw new LogicException(sprintf('An option named "%s" already exists.', $negatedName));
|
||||
}
|
||||
$this->negations[$negatedName] = $option->getName();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an InputOption by name.
|
||||
*
|
||||
* @param string $name The InputOption name
|
||||
*
|
||||
* @return InputOption A InputOption object
|
||||
* @return InputOption
|
||||
*
|
||||
* @throws InvalidArgumentException When option given doesn't exist
|
||||
*/
|
||||
public function getOption($name)
|
||||
public function getOption(string $name)
|
||||
{
|
||||
if (!$this->hasOption($name)) {
|
||||
throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
|
||||
@@ -270,11 +281,9 @@ class InputDefinition
|
||||
* This method can't be used to check if the user included the option when
|
||||
* executing the command (use getOption() instead).
|
||||
*
|
||||
* @param string $name The InputOption name
|
||||
*
|
||||
* @return bool true if the InputOption object exists, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($name)
|
||||
public function hasOption(string $name)
|
||||
{
|
||||
return isset($this->options[$name]);
|
||||
}
|
||||
@@ -282,7 +291,7 @@ class InputDefinition
|
||||
/**
|
||||
* Gets the array of InputOption objects.
|
||||
*
|
||||
* @return InputOption[] An array of InputOption objects
|
||||
* @return InputOption[]
|
||||
*/
|
||||
public function getOptions()
|
||||
{
|
||||
@@ -292,23 +301,27 @@ class InputDefinition
|
||||
/**
|
||||
* Returns true if an InputOption object exists by shortcut.
|
||||
*
|
||||
* @param string $name The InputOption shortcut
|
||||
*
|
||||
* @return bool true if the InputOption object exists, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShortcut($name)
|
||||
public function hasShortcut(string $name)
|
||||
{
|
||||
return isset($this->shortcuts[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if an InputOption object exists by negated name.
|
||||
*/
|
||||
public function hasNegation(string $name): bool
|
||||
{
|
||||
return isset($this->negations[$name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an InputOption by shortcut.
|
||||
*
|
||||
* @param string $shortcut The Shortcut name
|
||||
*
|
||||
* @return InputOption An InputOption object
|
||||
* @return InputOption
|
||||
*/
|
||||
public function getOptionForShortcut($shortcut)
|
||||
public function getOptionForShortcut(string $shortcut)
|
||||
{
|
||||
return $this->getOption($this->shortcutToName($shortcut));
|
||||
}
|
||||
@@ -342,14 +355,28 @@ class InputDefinition
|
||||
return $this->shortcuts[$shortcut];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the InputOption name given a negation.
|
||||
*
|
||||
* @throws InvalidArgumentException When option given does not exist
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
public function negationToName(string $negation): string
|
||||
{
|
||||
if (!isset($this->negations[$negation])) {
|
||||
throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $negation));
|
||||
}
|
||||
|
||||
return $this->negations[$negation];
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the synopsis.
|
||||
*
|
||||
* @param bool $short Whether to return the short version (with options folded) or not
|
||||
*
|
||||
* @return string The synopsis
|
||||
* @return string
|
||||
*/
|
||||
public function getSynopsis($short = false)
|
||||
public function getSynopsis(bool $short = false)
|
||||
{
|
||||
$elements = [];
|
||||
|
||||
@@ -368,7 +395,8 @@ class InputDefinition
|
||||
}
|
||||
|
||||
$shortcut = $option->getShortcut() ? sprintf('-%s|', $option->getShortcut()) : '';
|
||||
$elements[] = sprintf('[%s--%s%s]', $shortcut, $option->getName(), $value);
|
||||
$negation = $option->isNegatable() ? sprintf('|--no-%s', $option->getName()) : '';
|
||||
$elements[] = sprintf('[%s--%s%s%s]', $shortcut, $option->getName(), $value, $negation);
|
||||
}
|
||||
}
|
||||
|
||||
|
44
vendor/symfony/console/Input/InputInterface.php
vendored
44
vendor/symfony/console/Input/InputInterface.php
vendored
@@ -24,7 +24,7 @@ interface InputInterface
|
||||
/**
|
||||
* Returns the first argument from the raw parameters (not parsed).
|
||||
*
|
||||
* @return string|null The value of the first argument or null otherwise
|
||||
* @return string|null
|
||||
*/
|
||||
public function getFirstArgument();
|
||||
|
||||
@@ -39,9 +39,9 @@ interface InputInterface
|
||||
* @param string|array $values The values to look for in the raw parameters (can be an array)
|
||||
* @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
|
||||
*
|
||||
* @return bool true if the value is contained in the raw parameters
|
||||
* @return bool
|
||||
*/
|
||||
public function hasParameterOption($values, $onlyParams = false);
|
||||
public function hasParameterOption($values, bool $onlyParams = false);
|
||||
|
||||
/**
|
||||
* Returns the value of a raw option (not parsed).
|
||||
@@ -55,9 +55,9 @@ interface InputInterface
|
||||
* @param string|bool|int|float|array|null $default The default value to return if no result is found
|
||||
* @param bool $onlyParams Only check real parameters, skip those following an end of options (--) signal
|
||||
*
|
||||
* @return mixed The option value
|
||||
* @return mixed
|
||||
*/
|
||||
public function getParameterOption($values, $default = false, $onlyParams = false);
|
||||
public function getParameterOption($values, $default = false, bool $onlyParams = false);
|
||||
|
||||
/**
|
||||
* Binds the current Input instance with the given arguments and options.
|
||||
@@ -83,32 +83,27 @@ interface InputInterface
|
||||
/**
|
||||
* Returns the argument value for a given argument name.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
public function getArgument($name);
|
||||
public function getArgument(string $name);
|
||||
|
||||
/**
|
||||
* Sets an argument value by name.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
* @param mixed $value The argument value
|
||||
* @param mixed $value The argument value
|
||||
*
|
||||
* @throws InvalidArgumentException When argument given doesn't exist
|
||||
*/
|
||||
public function setArgument($name, $value);
|
||||
public function setArgument(string $name, $value);
|
||||
|
||||
/**
|
||||
* Returns true if an InputArgument object exists by name or position.
|
||||
*
|
||||
* @param string $name The argument name
|
||||
*
|
||||
* @return bool true if the InputArgument object exists, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasArgument($name);
|
||||
public function hasArgument(string $name);
|
||||
|
||||
/**
|
||||
* Returns all the given options merged with the default values.
|
||||
@@ -120,32 +115,27 @@ interface InputInterface
|
||||
/**
|
||||
* Returns the option value for a given option name.
|
||||
*
|
||||
* @param string $name The option name
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @throws InvalidArgumentException When option given doesn't exist
|
||||
*/
|
||||
public function getOption($name);
|
||||
public function getOption(string $name);
|
||||
|
||||
/**
|
||||
* Sets an option value by name.
|
||||
*
|
||||
* @param string $name The option name
|
||||
* @param mixed $value The option value
|
||||
* @param mixed $value The option value
|
||||
*
|
||||
* @throws InvalidArgumentException When option given doesn't exist
|
||||
*/
|
||||
public function setOption($name, $value);
|
||||
public function setOption(string $name, $value);
|
||||
|
||||
/**
|
||||
* Returns true if an InputOption object exists by name.
|
||||
*
|
||||
* @param string $name The InputOption name
|
||||
*
|
||||
* @return bool true if the InputOption object exists, false otherwise
|
||||
* @return bool
|
||||
*/
|
||||
public function hasOption($name);
|
||||
public function hasOption(string $name);
|
||||
|
||||
/**
|
||||
* Is this input means interactive?
|
||||
@@ -156,8 +146,6 @@ interface InputInterface
|
||||
|
||||
/**
|
||||
* Sets the input interactivity.
|
||||
*
|
||||
* @param bool $interactive If the input should be interactive
|
||||
*/
|
||||
public function setInteractive($interactive);
|
||||
public function setInteractive(bool $interactive);
|
||||
}
|
||||
|
32
vendor/symfony/console/Input/InputOption.php
vendored
32
vendor/symfony/console/Input/InputOption.php
vendored
@@ -41,6 +41,11 @@ class InputOption
|
||||
*/
|
||||
public const VALUE_IS_ARRAY = 8;
|
||||
|
||||
/**
|
||||
* The option may have either positive or negative value (e.g. --ansi or --no-ansi).
|
||||
*/
|
||||
public const VALUE_NEGATABLE = 16;
|
||||
|
||||
private $name;
|
||||
private $shortcut;
|
||||
private $mode;
|
||||
@@ -48,11 +53,9 @@ class InputOption
|
||||
private $description;
|
||||
|
||||
/**
|
||||
* @param string $name The option name
|
||||
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
* @param int|null $mode The option mode: One of the VALUE_* constants
|
||||
* @param string $description A description text
|
||||
* @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
|
||||
* @param string|array|null $shortcut The shortcuts, can be null, a string of shortcuts delimited by | or an array of shortcuts
|
||||
* @param int|null $mode The option mode: One of the VALUE_* constants
|
||||
* @param string|bool|int|float|array|null $default The default value (must be null for self::VALUE_NONE)
|
||||
*
|
||||
* @throws InvalidArgumentException If option mode is invalid or incompatible
|
||||
*/
|
||||
@@ -85,7 +88,7 @@ class InputOption
|
||||
|
||||
if (null === $mode) {
|
||||
$mode = self::VALUE_NONE;
|
||||
} elseif ($mode > 15 || $mode < 1) {
|
||||
} elseif ($mode >= (self::VALUE_NEGATABLE << 1) || $mode < 1) {
|
||||
throw new InvalidArgumentException(sprintf('Option mode "%s" is not valid.', $mode));
|
||||
}
|
||||
|
||||
@@ -97,6 +100,9 @@ class InputOption
|
||||
if ($this->isArray() && !$this->acceptValue()) {
|
||||
throw new InvalidArgumentException('Impossible to have an option mode VALUE_IS_ARRAY if the option does not accept a value.');
|
||||
}
|
||||
if ($this->isNegatable() && $this->acceptValue()) {
|
||||
throw new InvalidArgumentException('Impossible to have an option mode VALUE_NEGATABLE if the option also accepts a value.');
|
||||
}
|
||||
|
||||
$this->setDefault($default);
|
||||
}
|
||||
@@ -104,7 +110,7 @@ class InputOption
|
||||
/**
|
||||
* Returns the option shortcut.
|
||||
*
|
||||
* @return string|null The shortcut
|
||||
* @return string|null
|
||||
*/
|
||||
public function getShortcut()
|
||||
{
|
||||
@@ -114,7 +120,7 @@ class InputOption
|
||||
/**
|
||||
* Returns the option name.
|
||||
*
|
||||
* @return string The name
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
@@ -161,6 +167,11 @@ class InputOption
|
||||
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
|
||||
}
|
||||
|
||||
public function isNegatable(): bool
|
||||
{
|
||||
return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string|bool|int|float|array|null $default
|
||||
*/
|
||||
@@ -178,7 +189,7 @@ class InputOption
|
||||
}
|
||||
}
|
||||
|
||||
$this->default = $this->acceptValue() ? $default : false;
|
||||
$this->default = $this->acceptValue() || $this->isNegatable() ? $default : false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,7 +205,7 @@ class InputOption
|
||||
/**
|
||||
* Returns the description text.
|
||||
*
|
||||
* @return string The description text
|
||||
* @return string
|
||||
*/
|
||||
public function getDescription()
|
||||
{
|
||||
@@ -211,6 +222,7 @@ class InputOption
|
||||
return $option->getName() === $this->getName()
|
||||
&& $option->getShortcut() === $this->getShortcut()
|
||||
&& $option->getDefault() === $this->getDefault()
|
||||
&& $option->isNegatable() === $this->isNegatable()
|
||||
&& $option->isArray() === $this->isArray()
|
||||
&& $option->isValueRequired() === $this->isValueRequired()
|
||||
&& $option->isValueOptional() === $this->isValueOptional()
|
||||
|
Reference in New Issue
Block a user