Class Symfony\Component\Console\Helper\QuestionHelper

InheritanceSymfony\Component\Console\Helper\QuestionHelper » Symfony\Component\Console\Helper\Helper
ImplementsSymfony\Component\Console\Helper\HelperInterface
SubclassesSymfony\Component\Console\Helper\SymfonyQuestionHelper

The QuestionHelper class provides helpers to interact with the user.

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$helperSet Symfony\Component\Console\Helper\Helper

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
writeError() Outputs an error message. Symfony\Component\Console\Helper\QuestionHelper
writePrompt() Outputs the question prompt. Symfony\Component\Console\Helper\QuestionHelper

Method Details

ask() public method

Asks a question to the user.

public string ask ( Symfony\Component\Console\Input\InputInterface $input, Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Question\Question $question )
$input Symfony\Component\Console\Input\InputInterface

An InputInterface instance

$output Symfony\Component\Console\Output\OutputInterface

An OutputInterface instance

$question Symfony\Component\Console\Question\Question

The question to ask

return string

The user answer

throws Symfony\Component\Console\Exception\RuntimeException

If there is no data to read in the input stream

getInputStream() public method

Returns the helper's input stream.

public resource getInputStream ( )
getName() public method

{@inheritdoc}

public void getName ( )
setInputStream() public method

Sets the input stream to read from when interacting with the user.

This is mainly useful for testing purpose.

public void setInputStream ( $stream )
$stream resource

The input stream

throws Symfony\Component\Console\Exception\InvalidArgumentException

In case the stream is not a resource

writeError() protected method

Outputs an error message.

protected void writeError ( Symfony\Component\Console\Output\OutputInterface $output, Exception $error )
$output Symfony\Component\Console\Output\OutputInterface
$error Exception
writePrompt() protected method

Outputs the question prompt.

protected void writePrompt ( Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Question\Question $question )
$output Symfony\Component\Console\Output\OutputInterface
$question Symfony\Component\Console\Question\Question