Augmentation vers version 3.3.0
This commit is contained in:
@@ -134,22 +134,20 @@ class ChoiceQuestion extends Question
|
||||
$isAssoc = $this->isAssoc($choices);
|
||||
|
||||
return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
|
||||
// Collapse all spaces.
|
||||
$selectedChoices = str_replace(' ', '', $selected);
|
||||
|
||||
if ($multiselect) {
|
||||
// Check for a separated comma values
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selected, $matches)) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
|
||||
}
|
||||
$selectedChoices = explode(',', $selectedChoices);
|
||||
|
||||
$selectedChoices = array_map('trim', explode(',', $selected));
|
||||
} else {
|
||||
$selectedChoices = array($selected);
|
||||
$selectedChoices = [trim($selected)];
|
||||
}
|
||||
|
||||
$multiselectChoices = array();
|
||||
$multiselectChoices = [];
|
||||
foreach ($selectedChoices as $value) {
|
||||
$results = array();
|
||||
$results = [];
|
||||
foreach ($choices as $key => $choice) {
|
||||
if ($choice === $value) {
|
||||
$results[] = $key;
|
||||
|
||||
@@ -53,7 +53,7 @@ class ConfirmationQuestion extends Question
|
||||
return $answer && $answerIsTrue;
|
||||
}
|
||||
|
||||
return !$answer || $answerIsTrue;
|
||||
return '' === $answer || $answerIsTrue;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
10
vendor/symfony/console/Question/Question.php
vendored
10
vendor/symfony/console/Question/Question.php
vendored
@@ -156,11 +156,9 @@ class Question
|
||||
/**
|
||||
* Sets a validator for the question.
|
||||
*
|
||||
* @param callable|null $validator
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setValidator($validator)
|
||||
public function setValidator(callable $validator = null)
|
||||
{
|
||||
$this->validator = $validator;
|
||||
|
||||
@@ -216,11 +214,9 @@ class Question
|
||||
*
|
||||
* The normalizer can be a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @param callable $normalizer
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setNormalizer($normalizer)
|
||||
public function setNormalizer(callable $normalizer)
|
||||
{
|
||||
$this->normalizer = $normalizer;
|
||||
|
||||
@@ -232,7 +228,7 @@ class Question
|
||||
*
|
||||
* The normalizer can ba a callable (a string), a closure or a class implementing __invoke.
|
||||
*
|
||||
* @return callable
|
||||
* @return callable|null
|
||||
*/
|
||||
public function getNormalizer()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user