package and depencies
This commit is contained in:
@@ -20,17 +20,17 @@ use Symfony\Component\Console\Exception\InvalidArgumentException;
|
||||
*/
|
||||
class ChoiceQuestion extends Question
|
||||
{
|
||||
private $choices;
|
||||
private $multiselect = false;
|
||||
private $prompt = ' > ';
|
||||
private $errorMessage = 'Value "%s" is invalid';
|
||||
private array $choices;
|
||||
private bool $multiselect = false;
|
||||
private string $prompt = ' > ';
|
||||
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
|
||||
*/
|
||||
public function __construct(string $question, array $choices, $default = null)
|
||||
public function __construct(string $question, array $choices, mixed $default = null)
|
||||
{
|
||||
if (!$choices) {
|
||||
throw new \LogicException('Choice question must have at least 1 choice available.');
|
||||
@@ -45,10 +45,8 @@ class ChoiceQuestion extends Question
|
||||
|
||||
/**
|
||||
* Returns available choices.
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getChoices()
|
||||
public function getChoices(): array
|
||||
{
|
||||
return $this->choices;
|
||||
}
|
||||
@@ -60,7 +58,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setMultiselect(bool $multiselect)
|
||||
public function setMultiselect(bool $multiselect): static
|
||||
{
|
||||
$this->multiselect = $multiselect;
|
||||
$this->setValidator($this->getDefaultValidator());
|
||||
@@ -70,20 +68,16 @@ class ChoiceQuestion extends Question
|
||||
|
||||
/**
|
||||
* Returns whether the choices are multiselect.
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isMultiselect()
|
||||
public function isMultiselect(): bool
|
||||
{
|
||||
return $this->multiselect;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the prompt for choices.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getPrompt()
|
||||
public function getPrompt(): string
|
||||
{
|
||||
return $this->prompt;
|
||||
}
|
||||
@@ -93,7 +87,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setPrompt(string $prompt)
|
||||
public function setPrompt(string $prompt): static
|
||||
{
|
||||
$this->prompt = $prompt;
|
||||
|
||||
@@ -107,7 +101,7 @@ class ChoiceQuestion extends Question
|
||||
*
|
||||
* @return $this
|
||||
*/
|
||||
public function setErrorMessage(string $errorMessage)
|
||||
public function setErrorMessage(string $errorMessage): static
|
||||
{
|
||||
$this->errorMessage = $errorMessage;
|
||||
$this->setValidator($this->getDefaultValidator());
|
||||
|
Reference in New Issue
Block a user