Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. ChoiceQuestion.php

function ChoiceQuestion::__construct

Parameters

string $question The question to ask to the user:

array $choices The list of available choices:

string|bool|int|float|null $default The default answer to return:

Overrides Question::__construct

File

vendor/symfony/console/Question/ChoiceQuestion.php, line 32

Class

ChoiceQuestion
Represents a choice question.

Namespace

Symfony\Component\Console\Question

Code

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.');
    }
    parent::__construct($question, $default);
    $this->setValidator($this->getDefaultValidator());
    $this->setAutocompleterValues($choices);
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal