Laravel version update
Laravel version update
This commit is contained in:
@@ -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)
|
||||
{
|
||||
@@ -93,7 +95,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @param string $prompt
|
||||
*
|
||||
* @return ChoiceQuestion The current instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrompt($prompt)
|
||||
{
|
||||
@@ -109,7 +111,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @param string $errorMessage
|
||||
*
|
||||
* @return ChoiceQuestion The current instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setErrorMessage($errorMessage)
|
||||
{
|
||||
@@ -137,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);
|
||||
@@ -154,7 +156,7 @@ class ChoiceQuestion extends Question
|
||||
}
|
||||
}
|
||||
|
||||
if (count($results) > 1) {
|
||||
if (\count($results) > 1) {
|
||||
throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
|
||||
}
|
||||
|
||||
|
@@ -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
|
||||
@@ -46,7 +44,7 @@ class ConfirmationQuestion extends Question
|
||||
$regex = $this->trueAnswerRegex;
|
||||
|
||||
return function ($answer) use ($default, $regex) {
|
||||
if (is_bool($answer)) {
|
||||
if (\is_bool($answer)) {
|
||||
return $answer;
|
||||
}
|
||||
|
||||
|
30
vendor/symfony/console/Question/Question.php
vendored
30
vendor/symfony/console/Question/Question.php
vendored
@@ -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,23 +127,21 @@ 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
|
||||
*/
|
||||
public function setAutocompleterValues($values)
|
||||
{
|
||||
if (is_array($values)) {
|
||||
if (\is_array($values)) {
|
||||
$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,7 +158,7 @@ class Question
|
||||
*
|
||||
* @param null|callable $validator
|
||||
*
|
||||
* @return Question The current instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator(callable $validator = null)
|
||||
{
|
||||
@@ -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,7 +218,7 @@ class Question
|
||||
*
|
||||
* @param callable $normalizer
|
||||
*
|
||||
* @return Question The current instance
|
||||
* @return $this
|
||||
*/
|
||||
public function setNormalizer(callable $normalizer)
|
||||
{
|
||||
@@ -245,6 +241,6 @@ class Question
|
||||
|
||||
protected function isAssoc($array)
|
||||
{
|
||||
return (bool) count(array_filter(array_keys($array), 'is_string'));
|
||||
return (bool) \count(array_filter(array_keys($array), 'is_string'));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user