package and depencies

This commit is contained in:
RafficMohammed
2023-01-08 02:57:24 +05:30
parent d5332eb421
commit 1d54b8bc7f
4309 changed files with 193331 additions and 172289 deletions

View File

@@ -40,12 +40,12 @@ use Symfony\Component\Console\Exception\RuntimeException;
*/
class ArgvInput extends Input
{
private $tokens;
private $parsed;
private array $tokens;
private array $parsed;
public function __construct(array $argv = null, InputDefinition $definition = null)
{
$argv = $argv ?? $_SERVER['argv'] ?? [];
$argv ??= $_SERVER['argv'] ?? [];
// strip the application name
array_shift($argv);
@@ -60,9 +60,6 @@ class ArgvInput extends Input
$this->tokens = $tokens;
}
/**
* {@inheritdoc}
*/
protected function parse()
{
$parseOptions = true;
@@ -199,7 +196,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addShortOption(string $shortcut, $value)
private function addShortOption(string $shortcut, mixed $value)
{
if (!$this->definition->hasShortcut($shortcut)) {
throw new RuntimeException(sprintf('The "-%s" option does not exist.', $shortcut));
@@ -213,7 +210,7 @@ class ArgvInput extends Input
*
* @throws RuntimeException When option given doesn't exist
*/
private function addLongOption(string $name, $value)
private function addLongOption(string $name, mixed $value)
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
@@ -263,10 +260,7 @@ class ArgvInput extends Input
}
}
/**
* {@inheritdoc}
*/
public function getFirstArgument()
public function getFirstArgument(): ?string
{
$isOption = false;
foreach ($this->tokens as $i => $token) {
@@ -298,10 +292,7 @@ class ArgvInput extends Input
return null;
}
/**
* {@inheritdoc}
*/
public function hasParameterOption($values, bool $onlyParams = false)
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool
{
$values = (array) $values;
@@ -323,10 +314,7 @@ class ArgvInput extends Input
return false;
}
/**
* {@inheritdoc}
*/
public function getParameterOption($values, $default = false, bool $onlyParams = false)
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed
{
$values = (array) $values;
$tokens = $this->tokens;
@@ -356,10 +344,8 @@ class ArgvInput extends Input
/**
* Returns a stringified representation of the args passed to the command.
*
* @return string
*/
public function __toString()
public function __toString(): string
{
$tokens = array_map(function ($token) {
if (preg_match('{^(-[^=]+=)(.+)}', $token, $match)) {

View File

@@ -25,7 +25,7 @@ use Symfony\Component\Console\Exception\InvalidOptionException;
*/
class ArrayInput extends Input
{
private $parameters;
private array $parameters;
public function __construct(array $parameters, InputDefinition $definition = null)
{
@@ -34,10 +34,7 @@ class ArrayInput extends Input
parent::__construct($definition);
}
/**
* {@inheritdoc}
*/
public function getFirstArgument()
public function getFirstArgument(): ?string
{
foreach ($this->parameters as $param => $value) {
if ($param && \is_string($param) && '-' === $param[0]) {
@@ -50,10 +47,7 @@ class ArrayInput extends Input
return null;
}
/**
* {@inheritdoc}
*/
public function hasParameterOption($values, bool $onlyParams = false)
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool
{
$values = (array) $values;
@@ -74,10 +68,7 @@ class ArrayInput extends Input
return false;
}
/**
* {@inheritdoc}
*/
public function getParameterOption($values, $default = false, bool $onlyParams = false)
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false): mixed
{
$values = (array) $values;
@@ -100,10 +91,8 @@ class ArrayInput extends Input
/**
* Returns a stringified representation of the args passed to the command.
*
* @return string
*/
public function __toString()
public function __toString(): string
{
$params = [];
foreach ($this->parameters as $param => $val) {
@@ -117,16 +106,13 @@ class ArrayInput extends Input
$params[] = $param.('' != $val ? $glue.$this->escapeToken($val) : '');
}
} else {
$params[] = \is_array($val) ? implode(' ', array_map([$this, 'escapeToken'], $val)) : $this->escapeToken($val);
$params[] = \is_array($val) ? implode(' ', array_map($this->escapeToken(...), $val)) : $this->escapeToken($val);
}
}
return implode(' ', $params);
}
/**
* {@inheritdoc}
*/
protected function parse()
{
foreach ($this->parameters as $key => $value) {
@@ -148,7 +134,7 @@ class ArrayInput extends Input
*
* @throws InvalidOptionException When option given doesn't exist
*/
private function addShortOption(string $shortcut, $value)
private function addShortOption(string $shortcut, mixed $value)
{
if (!$this->definition->hasShortcut($shortcut)) {
throw new InvalidOptionException(sprintf('The "-%s" option does not exist.', $shortcut));
@@ -163,7 +149,7 @@ class ArrayInput extends Input
* @throws InvalidOptionException When option given doesn't exist
* @throws InvalidOptionException When a required value is missing
*/
private function addLongOption(string $name, $value)
private function addLongOption(string $name, mixed $value)
{
if (!$this->definition->hasOption($name)) {
if (!$this->definition->hasNegation($name)) {
@@ -194,12 +180,9 @@ class ArrayInput extends Input
/**
* Adds an argument value.
*
* @param string|int $name The argument name
* @param mixed $value The value for the argument
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
private function addArgument($name, $value)
private function addArgument(string|int $name, mixed $value)
{
if (!$this->definition->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));

View File

@@ -43,9 +43,6 @@ abstract class Input implements InputInterface, StreamableInputInterface
}
}
/**
* {@inheritdoc}
*/
public function bind(InputDefinition $definition)
{
$this->arguments = [];
@@ -60,9 +57,6 @@ abstract class Input implements InputInterface, StreamableInputInterface
*/
abstract protected function parse();
/**
* {@inheritdoc}
*/
public function validate()
{
$definition = $this->definition;
@@ -77,34 +71,22 @@ abstract class Input implements InputInterface, StreamableInputInterface
}
}
/**
* {@inheritdoc}
*/
public function isInteractive()
public function isInteractive(): bool
{
return $this->interactive;
}
/**
* {@inheritdoc}
*/
public function setInteractive(bool $interactive)
{
$this->interactive = $interactive;
}
/**
* {@inheritdoc}
*/
public function getArguments()
public function getArguments(): array
{
return array_merge($this->definition->getArgumentDefaults(), $this->arguments);
}
/**
* {@inheritdoc}
*/
public function getArgument(string $name)
public function getArgument(string $name): mixed
{
if (!$this->definition->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
@@ -113,10 +95,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
return $this->arguments[$name] ?? $this->definition->getArgument($name)->getDefault();
}
/**
* {@inheritdoc}
*/
public function setArgument(string $name, $value)
public function setArgument(string $name, mixed $value)
{
if (!$this->definition->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
@@ -125,26 +104,17 @@ abstract class Input implements InputInterface, StreamableInputInterface
$this->arguments[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function hasArgument(string $name)
public function hasArgument(string $name): bool
{
return $this->definition->hasArgument($name);
}
/**
* {@inheritdoc}
*/
public function getOptions()
public function getOptions(): array
{
return array_merge($this->definition->getOptionDefaults(), $this->options);
}
/**
* {@inheritdoc}
*/
public function getOption(string $name)
public function getOption(string $name): mixed
{
if ($this->definition->hasNegation($name)) {
if (null === $value = $this->getOption($this->definition->negationToName($name))) {
@@ -161,10 +131,7 @@ abstract class Input implements InputInterface, StreamableInputInterface
return \array_key_exists($name, $this->options) ? $this->options[$name] : $this->definition->getOption($name)->getDefault();
}
/**
* {@inheritdoc}
*/
public function setOption(string $name, $value)
public function setOption(string $name, mixed $value)
{
if ($this->definition->hasNegation($name)) {
$this->options[$this->definition->negationToName($name)] = !$value;
@@ -177,35 +144,24 @@ abstract class Input implements InputInterface, StreamableInputInterface
$this->options[$name] = $value;
}
/**
* {@inheritdoc}
*/
public function hasOption(string $name)
public function hasOption(string $name): bool
{
return $this->definition->hasOption($name) || $this->definition->hasNegation($name);
}
/**
* Escapes a token through escapeshellarg if it contains unsafe chars.
*
* @return string
*/
public function escapeToken(string $token)
public function escapeToken(string $token): string
{
return preg_match('{^[\w-]+$}', $token) ? $token : escapeshellarg($token);
}
/**
* {@inheritdoc}
*/
public function setStream($stream)
{
$this->stream = $stream;
}
/**
* {@inheritdoc}
*/
public function getStream()
{
return $this->stream;

View File

@@ -11,6 +11,10 @@
namespace Symfony\Component\Console\Input;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\CompletionSuggestions;
use Symfony\Component\Console\Completion\Suggestion;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\LogicException;
@@ -25,20 +29,22 @@ class InputArgument
public const OPTIONAL = 2;
public const IS_ARRAY = 4;
private $name;
private $mode;
private $default;
private $description;
private string $name;
private int $mode;
private string|int|bool|array|null|float $default;
private array|\Closure $suggestedValues;
private string $description;
/**
* @param string $name The argument name
* @param int|null $mode The argument mode: self::REQUIRED or self::OPTIONAL
* @param string $description A description text
* @param string|bool|int|float|array|null $default The default value (for self::OPTIONAL mode only)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @throws InvalidArgumentException When argument mode is not valid
*/
public function __construct(string $name, int $mode = null, string $description = '', $default = null)
public function __construct(string $name, int $mode = null, string $description = '', string|bool|int|float|array $default = null, \Closure|array $suggestedValues = [])
{
if (null === $mode) {
$mode = self::OPTIONAL;
@@ -49,16 +55,15 @@ class InputArgument
$this->name = $name;
$this->mode = $mode;
$this->description = $description;
$this->suggestedValues = $suggestedValues;
$this->setDefault($default);
}
/**
* Returns the argument name.
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
@@ -68,7 +73,7 @@ class InputArgument
*
* @return bool true if parameter mode is self::REQUIRED, false otherwise
*/
public function isRequired()
public function isRequired(): bool
{
return self::REQUIRED === (self::REQUIRED & $this->mode);
}
@@ -78,7 +83,7 @@ class InputArgument
*
* @return bool true if mode is self::IS_ARRAY, false otherwise
*/
public function isArray()
public function isArray(): bool
{
return self::IS_ARRAY === (self::IS_ARRAY & $this->mode);
}
@@ -86,12 +91,13 @@ class InputArgument
/**
* Sets the default value.
*
* @param string|bool|int|float|array|null $default
*
* @throws LogicException When incorrect default value is given
*/
public function setDefault($default = null)
public function setDefault(string|bool|int|float|array $default = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if ($this->isRequired() && null !== $default) {
throw new LogicException('Cannot set a default value except for InputArgument::OPTIONAL mode.');
}
@@ -109,20 +115,37 @@ class InputArgument
/**
* Returns the default value.
*
* @return string|bool|int|float|array|null
*/
public function getDefault()
public function getDefault(): string|bool|int|float|array|null
{
return $this->default;
}
public function hasCompletion(): bool
{
return [] !== $this->suggestedValues;
}
/**
* Adds suggestions to $suggestions for the current completion input.
*
* @see Command::complete()
*/
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
$values = $this->suggestedValues;
if ($values instanceof \Closure && !\is_array($values = $values($input))) {
throw new LogicException(sprintf('Closure for argument "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
}
if ($values) {
$suggestions->suggestValues($values);
}
}
/**
* Returns the description text.
*
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}

View File

@@ -28,13 +28,13 @@ use Symfony\Component\Console\Exception\LogicException;
*/
class InputDefinition
{
private $arguments;
private $requiredCount;
private $lastArrayArgument;
private $lastOptionalArgument;
private $options;
private $negations;
private $shortcuts;
private array $arguments = [];
private int $requiredCount = 0;
private ?InputArgument $lastArrayArgument = null;
private ?InputArgument $lastOptionalArgument = null;
private array $options = [];
private array $negations = [];
private array $shortcuts = [];
/**
* @param array $definition An array of InputArgument and InputOption instance
@@ -124,13 +124,9 @@ class InputDefinition
/**
* Returns an InputArgument by name or by position.
*
* @param string|int $name The InputArgument name or position
*
* @return InputArgument
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
public function getArgument($name)
public function getArgument(string|int $name): InputArgument
{
if (!$this->hasArgument($name)) {
throw new InvalidArgumentException(sprintf('The "%s" argument does not exist.', $name));
@@ -143,12 +139,8 @@ class InputDefinition
/**
* Returns true if an InputArgument object exists by name or position.
*
* @param string|int $name The InputArgument name or position
*
* @return bool
*/
public function hasArgument($name)
public function hasArgument(string|int $name): bool
{
$arguments = \is_int($name) ? array_values($this->arguments) : $this->arguments;
@@ -160,27 +152,23 @@ class InputDefinition
*
* @return InputArgument[]
*/
public function getArguments()
public function getArguments(): array
{
return $this->arguments;
}
/**
* Returns the number of InputArguments.
*
* @return int
*/
public function getArgumentCount()
public function getArgumentCount(): int
{
return null !== $this->lastArrayArgument ? \PHP_INT_MAX : \count($this->arguments);
}
/**
* Returns the number of required InputArguments.
*
* @return int
*/
public function getArgumentRequiredCount()
public function getArgumentRequiredCount(): int
{
return $this->requiredCount;
}
@@ -188,7 +176,7 @@ class InputDefinition
/**
* @return array<string|bool|int|float|array|null>
*/
public function getArgumentDefaults()
public function getArgumentDefaults(): array
{
$values = [];
foreach ($this->arguments as $argument) {
@@ -262,11 +250,9 @@ class InputDefinition
/**
* Returns an InputOption by name.
*
* @return InputOption
*
* @throws InvalidArgumentException When option given doesn't exist
*/
public function getOption(string $name)
public function getOption(string $name): InputOption
{
if (!$this->hasOption($name)) {
throw new InvalidArgumentException(sprintf('The "--%s" option does not exist.', $name));
@@ -280,10 +266,8 @@ class InputDefinition
*
* This method can't be used to check if the user included the option when
* executing the command (use getOption() instead).
*
* @return bool
*/
public function hasOption(string $name)
public function hasOption(string $name): bool
{
return isset($this->options[$name]);
}
@@ -293,17 +277,15 @@ class InputDefinition
*
* @return InputOption[]
*/
public function getOptions()
public function getOptions(): array
{
return $this->options;
}
/**
* Returns true if an InputOption object exists by shortcut.
*
* @return bool
*/
public function hasShortcut(string $name)
public function hasShortcut(string $name): bool
{
return isset($this->shortcuts[$name]);
}
@@ -318,10 +300,8 @@ class InputDefinition
/**
* Gets an InputOption by shortcut.
*
* @return InputOption
*/
public function getOptionForShortcut(string $shortcut)
public function getOptionForShortcut(string $shortcut): InputOption
{
return $this->getOption($this->shortcutToName($shortcut));
}
@@ -329,7 +309,7 @@ class InputDefinition
/**
* @return array<string|bool|int|float|array|null>
*/
public function getOptionDefaults()
public function getOptionDefaults(): array
{
$values = [];
foreach ($this->options as $option) {
@@ -373,10 +353,8 @@ class InputDefinition
/**
* Gets the synopsis.
*
* @return string
*/
public function getSynopsis(bool $short = false)
public function getSynopsis(bool $short = false): string
{
$elements = [];

View File

@@ -18,15 +18,16 @@ use Symfony\Component\Console\Exception\RuntimeException;
* InputInterface is the interface implemented by all input classes.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @method string __toString() Returns a stringified representation of the args passed to the command.
* InputArguments MUST be escaped as well as the InputOption values passed to the command.
*/
interface InputInterface
{
/**
* Returns the first argument from the raw parameters (not parsed).
*
* @return string|null
*/
public function getFirstArgument();
public function getFirstArgument(): ?string;
/**
* Returns true if the raw parameters (not parsed) contain a value.
@@ -38,10 +39,8 @@ 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
*/
public function hasParameterOption($values, bool $onlyParams = false);
public function hasParameterOption(string|array $values, bool $onlyParams = false): bool;
/**
* Returns the value of a raw option (not parsed).
@@ -57,7 +56,7 @@ interface InputInterface
*
* @return mixed
*/
public function getParameterOption($values, $default = false, bool $onlyParams = false);
public function getParameterOption(string|array $values, string|bool|int|float|array|null $default = false, bool $onlyParams = false);
/**
* Binds the current Input instance with the given arguments and options.
@@ -78,7 +77,7 @@ interface InputInterface
*
* @return array<string|bool|int|float|array|null>
*/
public function getArguments();
public function getArguments(): array;
/**
* Returns the argument value for a given argument name.
@@ -92,25 +91,21 @@ interface InputInterface
/**
* Sets an argument value by name.
*
* @param mixed $value The argument value
*
* @throws InvalidArgumentException When argument given doesn't exist
*/
public function setArgument(string $name, $value);
public function setArgument(string $name, mixed $value);
/**
* Returns true if an InputArgument object exists by name or position.
*
* @return bool
*/
public function hasArgument(string $name);
public function hasArgument(string $name): bool;
/**
* Returns all the given options merged with the default values.
*
* @return array<string|bool|int|float|array|null>
*/
public function getOptions();
public function getOptions(): array;
/**
* Returns the option value for a given option name.
@@ -124,25 +119,19 @@ interface InputInterface
/**
* Sets an option value by name.
*
* @param mixed $value The option value
*
* @throws InvalidArgumentException When option given doesn't exist
*/
public function setOption(string $name, $value);
public function setOption(string $name, mixed $value);
/**
* Returns true if an InputOption object exists by name.
*
* @return bool
*/
public function hasOption(string $name);
public function hasOption(string $name): bool;
/**
* Is this input means interactive?
*
* @return bool
*/
public function isInteractive();
public function isInteractive(): bool;
/**
* Sets the input interactivity.

View File

@@ -11,6 +11,10 @@
namespace Symfony\Component\Console\Input;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Completion\CompletionInput;
use Symfony\Component\Console\Completion\CompletionSuggestions;
use Symfony\Component\Console\Completion\Suggestion;
use Symfony\Component\Console\Exception\InvalidArgumentException;
use Symfony\Component\Console\Exception\LogicException;
@@ -46,20 +50,22 @@ class InputOption
*/
public const VALUE_NEGATABLE = 16;
private $name;
private $shortcut;
private $mode;
private $default;
private $description;
private string $name;
private string|array|null $shortcut;
private int $mode;
private string|int|bool|array|null|float $default;
private array|\Closure $suggestedValues;
private string $description;
/**
* @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)
* @param array|\Closure(CompletionInput,CompletionSuggestions):list<string|Suggestion> $suggestedValues The values used for input completion
*
* @throws InvalidArgumentException If option mode is invalid or incompatible
*/
public function __construct(string $name, $shortcut = null, int $mode = null, string $description = '', $default = null)
public function __construct(string $name, string|array $shortcut = null, int $mode = null, string $description = '', string|bool|int|float|array $default = null, array|\Closure $suggestedValues = [])
{
if (str_starts_with($name, '--')) {
$name = substr($name, 2);
@@ -96,7 +102,11 @@ class InputOption
$this->shortcut = $shortcut;
$this->mode = $mode;
$this->description = $description;
$this->suggestedValues = $suggestedValues;
if ($suggestedValues && !$this->acceptValue()) {
throw new LogicException('Cannot set suggested values if the option does not accept a value.');
}
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.');
}
@@ -109,20 +119,16 @@ class InputOption
/**
* Returns the option shortcut.
*
* @return string|null
*/
public function getShortcut()
public function getShortcut(): ?string
{
return $this->shortcut;
}
/**
* Returns the option name.
*
* @return string
*/
public function getName()
public function getName(): string
{
return $this->name;
}
@@ -132,7 +138,7 @@ class InputOption
*
* @return bool true if value mode is not self::VALUE_NONE, false otherwise
*/
public function acceptValue()
public function acceptValue(): bool
{
return $this->isValueRequired() || $this->isValueOptional();
}
@@ -142,7 +148,7 @@ class InputOption
*
* @return bool true if value mode is self::VALUE_REQUIRED, false otherwise
*/
public function isValueRequired()
public function isValueRequired(): bool
{
return self::VALUE_REQUIRED === (self::VALUE_REQUIRED & $this->mode);
}
@@ -152,7 +158,7 @@ class InputOption
*
* @return bool true if value mode is self::VALUE_OPTIONAL, false otherwise
*/
public function isValueOptional()
public function isValueOptional(): bool
{
return self::VALUE_OPTIONAL === (self::VALUE_OPTIONAL & $this->mode);
}
@@ -162,7 +168,7 @@ class InputOption
*
* @return bool true if mode is self::VALUE_IS_ARRAY, false otherwise
*/
public function isArray()
public function isArray(): bool
{
return self::VALUE_IS_ARRAY === (self::VALUE_IS_ARRAY & $this->mode);
}
@@ -172,11 +178,11 @@ class InputOption
return self::VALUE_NEGATABLE === (self::VALUE_NEGATABLE & $this->mode);
}
/**
* @param string|bool|int|float|array|null $default
*/
public function setDefault($default = null)
public function setDefault(string|bool|int|float|array $default = null)
{
if (1 > \func_num_args()) {
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
}
if (self::VALUE_NONE === (self::VALUE_NONE & $this->mode) && null !== $default) {
throw new LogicException('Cannot set a default value when using InputOption::VALUE_NONE mode.');
}
@@ -194,30 +200,45 @@ class InputOption
/**
* Returns the default value.
*
* @return string|bool|int|float|array|null
*/
public function getDefault()
public function getDefault(): string|bool|int|float|array|null
{
return $this->default;
}
/**
* Returns the description text.
*
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
public function hasCompletion(): bool
{
return [] !== $this->suggestedValues;
}
/**
* Adds suggestions to $suggestions for the current completion input.
*
* @see Command::complete()
*/
public function complete(CompletionInput $input, CompletionSuggestions $suggestions): void
{
$values = $this->suggestedValues;
if ($values instanceof \Closure && !\is_array($values = $values($input))) {
throw new LogicException(sprintf('Closure for option "%s" must return an array. Got "%s".', $this->name, get_debug_type($values)));
}
if ($values) {
$suggestions->suggestValues($values);
}
}
/**
* Checks whether the given option equals this one.
*
* @return bool
*/
public function equals(self $option)
public function equals(self $option): bool
{
return $option->getName() === $this->getName()
&& $option->getShortcut() === $this->getShortcut()

View File

@@ -24,6 +24,9 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
*/
class StringInput extends ArgvInput
{
/**
* @deprecated since Symfony 6.1
*/
public const REGEX_STRING = '([^\s]+?)(?:\s|(?<!\\\\)"|(?<!\\\\)\'|$)';
public const REGEX_UNQUOTED_STRING = '([^\s\\\\]+?)';
public const REGEX_QUOTED_STRING = '(?:"([^"\\\\]*(?:\\\\.[^"\\\\]*)*)"|\'([^\'\\\\]*(?:\\\\.[^\'\\\\]*)*)\')';