diff options
author | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:24:35 -0800 |
---|---|---|
committer | Frédéric Guillot <fred@kanboard.net> | 2017-12-15 11:55:42 -0800 |
commit | a93b8e10f5954be0853eec693c13e84c4bd9e6f2 (patch) | |
tree | eda5de9494b819235616e8623bb3393e9cc373af /vendor/symfony/console/Question | |
parent | 2c72a283f2d51034f85f4e2ca8b194d304a3c433 (diff) |
Kanboard requires at least PHP 5.6 now
Diffstat (limited to 'vendor/symfony/console/Question')
-rw-r--r-- | vendor/symfony/console/Question/ChoiceQuestion.php | 24 | ||||
-rw-r--r-- | vendor/symfony/console/Question/ConfirmationQuestion.php | 2 | ||||
-rw-r--r-- | vendor/symfony/console/Question/Question.php | 30 |
3 files changed, 31 insertions, 25 deletions
diff --git a/vendor/symfony/console/Question/ChoiceQuestion.php b/vendor/symfony/console/Question/ChoiceQuestion.php index 2c40638d..46cc72a3 100644 --- a/vendor/symfony/console/Question/ChoiceQuestion.php +++ b/vendor/symfony/console/Question/ChoiceQuestion.php @@ -26,14 +26,16 @@ class ChoiceQuestion extends Question private $errorMessage = 'Value "%s" is invalid'; /** - * Constructor. - * * @param string $question The question to ask to the user * @param array $choices The list of available choices * @param mixed $default The default answer to return */ public function __construct($question, array $choices, $default = null) { + if (!$choices) { + throw new \LogicException('Choice question must have at least 1 choice available.'); + } + parent::__construct($question, $default); $this->choices = $choices; @@ -58,7 +60,7 @@ class ChoiceQuestion extends Question * * @param bool $multiselect * - * @return ChoiceQuestion The current instance + * @return $this */ public function setMultiselect($multiselect) { @@ -69,6 +71,16 @@ class ChoiceQuestion extends Question } /** + * Returns whether the choices are multiselect. + * + * @return bool + */ + public function isMultiselect() + { + return $this->multiselect; + } + + /** * Gets the prompt for choices. * * @return string @@ -83,7 +95,7 @@ class ChoiceQuestion extends Question * * @param string $prompt * - * @return ChoiceQuestion The current instance + * @return $this */ public function setPrompt($prompt) { @@ -99,7 +111,7 @@ class ChoiceQuestion extends Question * * @param string $errorMessage * - * @return ChoiceQuestion The current instance + * @return $this */ public function setErrorMessage($errorMessage) { @@ -127,7 +139,7 @@ class ChoiceQuestion extends Question if ($multiselect) { // Check for a separated comma values - if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) { + if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) { throw new InvalidArgumentException(sprintf($errorMessage, $selected)); } $selectedChoices = explode(',', $selectedChoices); diff --git a/vendor/symfony/console/Question/ConfirmationQuestion.php b/vendor/symfony/console/Question/ConfirmationQuestion.php index 29d98879..40f54b4e 100644 --- a/vendor/symfony/console/Question/ConfirmationQuestion.php +++ b/vendor/symfony/console/Question/ConfirmationQuestion.php @@ -21,8 +21,6 @@ class ConfirmationQuestion extends Question private $trueAnswerRegex; /** - * Constructor. - * * @param string $question The question to ask to the user * @param bool $default The default answer to return, true or false * @param string $trueAnswerRegex A regex to match the "yes" answer diff --git a/vendor/symfony/console/Question/Question.php b/vendor/symfony/console/Question/Question.php index ab415c26..63afbc4c 100644 --- a/vendor/symfony/console/Question/Question.php +++ b/vendor/symfony/console/Question/Question.php @@ -31,8 +31,6 @@ class Question private $normalizer; /** - * Constructor. - * * @param string $question The question to ask to the user * @param mixed $default The default answer to return if the user enters nothing */ @@ -77,7 +75,7 @@ class Question * * @param bool $hidden * - * @return Question The current instance + * @return $this * * @throws LogicException In case the autocompleter is also used */ @@ -107,7 +105,7 @@ class Question * * @param bool $fallback * - * @return Question The current instance + * @return $this */ public function setHiddenFallback($fallback) { @@ -119,7 +117,7 @@ class Question /** * Gets values for the autocompleter. * - * @return null|array|\Traversable + * @return null|iterable */ public function getAutocompleterValues() { @@ -129,9 +127,9 @@ class Question /** * Sets values for the autocompleter. * - * @param null|array|\Traversable $values + * @param null|iterable $values * - * @return Question The current instance + * @return $this * * @throws InvalidArgumentException * @throws LogicException @@ -142,10 +140,8 @@ class Question $values = $this->isAssoc($values) ? array_merge(array_keys($values), array_values($values)) : array_values($values); } - if (null !== $values && !is_array($values)) { - if (!$values instanceof \Traversable || !$values instanceof \Countable) { - throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or an object implementing both `Countable` and `Traversable` interfaces.'); - } + if (null !== $values && !is_array($values) && !$values instanceof \Traversable) { + throw new InvalidArgumentException('Autocompleter values can be either an array, `null` or a `Traversable` object.'); } if ($this->hidden) { @@ -162,9 +158,9 @@ class Question * * @param null|callable $validator * - * @return Question The current instance + * @return $this */ - public function setValidator($validator) + public function setValidator(callable $validator = null) { $this->validator = $validator; @@ -188,9 +184,9 @@ class Question * * @param null|int $attempts * - * @return Question The current instance + * @return $this * - * @throws InvalidArgumentException In case the number of attempts is invalid. + * @throws InvalidArgumentException in case the number of attempts is invalid */ public function setMaxAttempts($attempts) { @@ -222,9 +218,9 @@ class Question * * @param callable $normalizer * - * @return Question The current instance + * @return $this */ - public function setNormalizer($normalizer) + public function setNormalizer(callable $normalizer) { $this->normalizer = $normalizer; |