@param string|string[] $question
@param string[]        $choices
@param string          $default
@param InputInterface  $input
@param OutputInterface $output

@return string|null
610
private function choice($question, array $choices, $default, InputInterface $input, OutputInterface $output)
    {
        $helper = new QuestionHelper();

        $result = $helper->ask($input, $output, new ChoiceQuestion(
            $question,
            $choices,
            $choices[$default]
        ));

        $output->writeln('');

        return $result;
    }
1222436
protected function ask($question, $default = null, Closure $validator = null)
    {
        if ($default) {
            $question .= " [$default]";
        }

        $question = new Question($question . "\n > ", $default);

        if ($validator) {
            $question->setValidator($validator);
        }

        return trim($this->getHelper('question')->ask($this->input, $this->output, $question));
    }
1077879
public function serialize(ChoiceQuestion $choiceQuestion, array $options = [])
    {
        $serialized = [
            'random' => $choiceQuestion->getShuffle(),
            'multiple' => $choiceQuestion->isMultiple(),
            'numbering' => $choiceQuestion->getNumbering(),
            'direction' => $choiceQuestion->getDirection(),
        ];

        // Serializes choices
        $choices = $this->serializeChoices($choiceQuestion, $options);

        if ($choiceQuestion->getShuffle() && in_array(Transfer::SHUFFLE_ANSWERS, $options)) {
            shuffle($choices);
        }

        $serialized['choices'] = $choices;

        if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
            $serialized['solutions'] = $this->serializeSolutions($choiceQuestion);
        }

        return $serialized;
    }
622396
public function ask($choice = null)
    {
        $responseCollection = new PredefinedResponseCollection();

        foreach ($this->metadataSourceFinder->getAllAdapters() as $backend) {
            /* @var $backend \CrudGenerator\Metadata\MetaDataSource */
            if (null === $backend->getFalseDependencies()) {
                $responseCollection->append(
                    new PredefinedResponse($backend->getMetadataDaoFactory(), $backend->getDefinition(), $backend)
                );
            }
        }

        $question = new QuestionWithPredefinedResponse(
            "Select source",
            self::QUESTION_KEY,
            $responseCollection
        );
        $question->setPreselectedResponse($choice);
        $question->setShutdownWithoutResponse(true);

        return $this->context->askCollection($question);
    }
455599
public function serialize(Item $question, array $options = [])
    {
        // Serialize specific data for the item type
        $serialized = $this->serializeQuestionType($question, $options);

        if (1 === preg_match('#^application\/x\.[^/]+\+json$#', $question->getMimeType())) {
            $canEdit = $this->tokenStorage->getToken() && $this->tokenStorage->getToken()->getUser() instanceof User ?
                $this->container->get('ujm_exo.manager.item')->canEdit($question, $this->tokenStorage->getToken()->getUser()) :
                false;
            // Adds minimal information
            $serialized = array_merge($serialized, [
                'id' => $question->getUuid(),
                'autoId' => $question->getId(),
                'type' => $question->getMimeType(),
                'content' => $question->getContent(),
                'title' => $question->getTitle(),
                'meta' => $this->serializeMetadata($question, $options),
                'score' => json_decode($question->getScoreRule(), true),
                'rights' => ['edit' => $canEdit],
            ]);

            // Adds full definition of the item
            if (!in_array(Transfer::MINIMAL, $options)) {
                $serialized = array_merge($serialized, [
                    'description' => $question->getDescription(),
                    'hints' => $this->serializeHints($question, $options),
                    'objects' => $this->serializeObjects($question),
                    'resources' => $this->serializeResources($question),
                    'tags' => $this->serializeTags($question),
                ]);

                // Adds item feedback
                if (in_array(Transfer::INCLUDE_SOLUTIONS, $options)) {
                    $serialized['feedback'] = $question->getFeedback();
                }
            }
        } else {
            $serialized = array_merge($serialized, [
                'id' => $question->getUuid(),
                'type' => $question->getMimeType(),
                'title' => $question->getTitle(),
                'meta' => $this->serializeMetadata($question, $options),
            ]);

            // Adds full definition of the item
            if (!in_array(Transfer::MINIMAL, $options)) {
                $serialized = array_merge($serialized, [
                    'description' => $question->getDescription(),
                    'tags' => $this->serializeTags($question),
                ]);
            }
        }

        return $serialized;
    }
1168993
private function askAndValidate(InputInterface $input, OutputInterface $output, $questionText, $default, $validator)
    {
        $questionHelper = $this->getQuestionHelper();

        // NEXT_MAJOR: Remove this BC code for SensioGeneratorBundle 2.3/2.4 after dropping support for Symfony 2.3
        if ($questionHelper instanceof DialogHelper) {
            return $questionHelper->askAndValidate($output, $questionHelper->getQuestion($questionText, $default), $validator, false, $default);
        }

        $question = new Question($questionHelper->getQuestion($questionText, $default), $default);

        $question->setValidator($validator);

        return $questionHelper->ask($input, $output, $question);
    }
1374719
public function prompt($question, $default = null, $marker = ': ')
    {
        if (isset($default) && strpos($question, '[') === false) {
            $question .= ' [default: ' . $default . ']';
        }

        $this->out($question . $marker);

        $input = $this->in();

        if ($input === '') {
            return $default;
        }

        return $input;
    }
994329
public function askThenRemove(InputInterface $input, OverwritableOutputInterface $output, Question $question)
    {
        // Following suit of ask().
        if (!$input->isInteractive()) {
            return $question->getDefault();
        }

        $this->remove = true;
        $this->question = $question;
        $this->output = $output;
        $this->autocomplete = $this->question->getAutocompleterValues() !== null && $this->hasSttyAvailable();

        $this->output->capture();

        // Wrap normalizer to remove latest question & answer since
        // it is called for each iteration if answer is not valid.
        $normalizer = $question->getNormalizer();
        $question->setNormalizer(function ($value) use ($normalizer) {
            $this->output->remove();
            $this->output->capture();

            if (is_callable($normalizer)) {
                return $normalizer($value);
            }

            return $value;
        });

        try {
            $value = $this->ask($input, $this->output, $question);
        } finally {
            $this->remove = false;
            $this->question = null;
            $this->output->remove();
            $this->output = null;
        }

        return $value;
    }
453918
public function choose($question, array $options, $default, $error_message)
	{
		/** @var QuestionHelper $helper */
		$helper = $this->_helperSet->get('question');
		$choice_question = new ChoiceQuestion('<question>' . $question . '</question> ', $options, $default);
		$choice_question->setErrorMessage($error_message);

		return $helper->ask($this->_input, $this->_output, $choice_question);
	}
930523
public function ask($question, $default = null)
    {
        $question = new Question("<question>$question</question> ", $default);

        return $this->helper('question')->ask($this->input, $this->output, $question);
    }
732766
public function confirm($question, $default = false)
    {
        $que = new ConfirmationQuestion($question, $default);
        $helper = new SymfonyQuestionHelper();
        return $helper->ask($this->input, $this->output, $que);
    }
1075761
public function in(string $question, string $default = '')
    {
        $input = $this->climate->input($question);
        return $input->prompt() ?: $default;
    }
369116
public static function question(string $question, string $default = '', \Closure $validator = null): string
    {
        return Question::ask($question, $default, $validator);
    }
1350997
protected function question(string $question, $default = null)
	{
		return (new Question($this->input, $this->output))->ask($question, $default);
	}
198861
public function ask(InputInterface $input, OutputInterface $output, Question $question)
    {
        if ($output instanceof ConsoleOutputInterface) {
            $output = $output->getErrorOutput();
        }

        if (!$input->isInteractive()) {
            $default = $question->getDefault();

            if (null === $default) {
                return $default;
            }

            if ($validator = $question->getValidator()) {
                return \call_user_func($question->getValidator(), $default);
            } elseif ($question instanceof ChoiceQuestion) {
                $choices = $question->getChoices();

                if (!$question->isMultiselect()) {
                    return isset($choices[$default]) ? $choices[$default] : $default;
                }

                $default = explode(',', $default);
                foreach ($default as $k => $v) {
                    $v = trim($v);
                    $default[$k] = isset($choices[$v]) ? $choices[$v] : $v;
                }
            }

            return $default;
        }

        if ($input instanceof StreamableInputInterface && $stream = $input->getStream()) {
            $this->inputStream = $stream;
        }

        if (!$question->getValidator()) {
            return $this->doAsk($output, $question);
        }

        $interviewer = function () use ($output, $question) {
            return $this->doAsk($output, $question);
        };

        return $this->validateAttempts($interviewer, $output, $question);
    }
541575
protected function ask($question, $default = null, $validator = null)
    {
        return $this->output->ask($question, $default, $validator);
    }
643137
protected function writePrompt(OutputInterface $output, Question $question, $formats = [])
	{
		$formats = array_replace($this->formats, $formats);

		$output->write(sprintf($formats['question_format'], $question->getQuestion()));

		$default = $question->getDefault();
		if (! is_null($default)) {
			if ($question instanceof ConfirmationQuestion) {
				$default = $default ? "yes" : "no";
			}

			$output->write(sprintf($formats['default_format'], $default));
		}

		if ($question instanceof ChoiceQuestion) {
			$messages = [];
			foreach ($question->getChoices() as $key => $value) {
				$messages[] = sprintf($formats['choice_format'], $key, substr($value, 0));
			}

			$output->writeln("");
			$output->writeln("");
			$output->writeln(implode(PHP_EOL, $messages));
			$output->writeln("");
			$output->write("> ");
		} else {
			$output->write(": ");
		}
	}