PHP 8 Compatibility
This commit is contained in:
@@ -131,13 +131,19 @@ class ChoiceQuestion extends Question
|
||||
return function ($selected) use ($choices, $errorMessage, $multiselect, $isAssoc) {
|
||||
if ($multiselect) {
|
||||
// Check for a separated comma values
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selected, $matches)) {
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
|
||||
}
|
||||
|
||||
$selectedChoices = array_map('trim', explode(',', $selected));
|
||||
$selectedChoices = explode(',', (string) $selected);
|
||||
} else {
|
||||
$selectedChoices = [trim($selected)];
|
||||
$selectedChoices = [$selected];
|
||||
}
|
||||
|
||||
if ($this->isTrimmable()) {
|
||||
foreach ($selectedChoices as $k => $v) {
|
||||
$selectedChoices[$k] = trim((string) $v);
|
||||
}
|
||||
}
|
||||
|
||||
$multiselectChoices = [];
|
||||
@@ -150,7 +156,7 @@ class ChoiceQuestion extends Question
|
||||
}
|
||||
|
||||
if (\count($results) > 1) {
|
||||
throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of %s.', implode(' or ', $results)));
|
||||
throw new InvalidArgumentException(sprintf('The provided answer is ambiguous. Value should be one of "%s".', implode('" or "', $results)));
|
||||
}
|
||||
|
||||
$result = array_search($value, $choices);
|
||||
|
||||
Reference in New Issue
Block a user