mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-26 12:08:47 +02:00
N°8834 - Add compatibility with PHP 8.4 (#819)
* N°8834 - Add compatibility with PHP 8.4 * Rollback of scssphp/scssphp version upgrade due to compilation error
This commit is contained in:
@@ -26,11 +26,11 @@ class ChoiceQuestion extends Question
|
||||
private string $errorMessage = 'Value "%s" is invalid';
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @param string $question The question to ask to the user
|
||||
* @param array<string|bool|int|float|\Stringable> $choices The list of available choices
|
||||
* @param string|bool|int|float|null $default The default answer to return
|
||||
*/
|
||||
public function __construct(string $question, array $choices, mixed $default = null)
|
||||
public function __construct(string $question, array $choices, string|bool|int|float|null $default = null)
|
||||
{
|
||||
if (!$choices) {
|
||||
throw new \LogicException('Choice question must have at least 1 choice available.');
|
||||
@@ -44,7 +44,7 @@ class ChoiceQuestion extends Question
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available choices.
|
||||
* @return array<string|bool|int|float|\Stringable>
|
||||
*/
|
||||
public function getChoices(): array
|
||||
{
|
||||
@@ -120,7 +120,7 @@ class ChoiceQuestion extends Question
|
||||
if ($multiselect) {
|
||||
// Check for a separated comma values
|
||||
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', (string) $selected, $matches)) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
|
||||
throw new InvalidArgumentException(\sprintf($errorMessage, $selected));
|
||||
}
|
||||
|
||||
$selectedChoices = explode(',', (string) $selected);
|
||||
@@ -144,7 +144,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);
|
||||
@@ -160,7 +160,7 @@ class ChoiceQuestion extends Question
|
||||
}
|
||||
|
||||
if (false === $result) {
|
||||
throw new InvalidArgumentException(sprintf($errorMessage, $value));
|
||||
throw new InvalidArgumentException(\sprintf($errorMessage, $value));
|
||||
}
|
||||
|
||||
// For associative choices, consistently return the key as string:
|
||||
|
||||
Reference in New Issue
Block a user