Methods summary
public
|
|
public
integer|string|array
|
#
select( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, array $choices, boolean|string $default = null, boolean|integer $attempts = false, string $errorMessage = 'Value "%s" is invalid', boolean $multiselect = false )
Asks the user to select a value.
Asks the user to select a value.
Parameters
- $output
- An Output instance
- $question
- The question to ask
- $choices
- List of choices to pick from
- $default
- The default answer if the user enters nothing
- $attempts
- Max number of times to ask before giving up (false by default, which means infinite)
- $errorMessage
- Message which will be shown if invalid value from choice list would be picked
- $multiselect
- Select more than one value separated by comma
Returns
integer|string|array The selected value or values (the key of the choices array)
Throws
|
public
string
|
#
ask( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, string $default = null, array $autocomplete = null )
Asks a question to the user.
Asks a question to the user.
Parameters
- $output
- An Output instance
- $question
- The question to ask
- $default
- The default answer if none is given by the user
- $autocomplete
- List of values to autocomplete
Returns
string The user answer
Throws
|
public
boolean
|
#
askConfirmation( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, boolean $default = true )
Asks a confirmation to the user.
Asks a confirmation to the user.
The question will be asked until the user answers by nothing, yes, or no.
Parameters
- $output
- An Output instance
- $question
- The question to ask
- $default
- The default answer if the user enters nothing
Returns
boolean true if the user has confirmed, false otherwise
|
public
string
|
#
askHiddenResponse( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, boolean $fallback = true )
Asks a question to the user, the response is hidden.
Asks a question to the user, the response is hidden.
Parameters
- $output
- An Output instance
- $question
- The question
- $fallback
- In case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
string The answer
Throws
|
public
mixed
|
#
askAndValidate( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, callable $validator, integer|false $attempts = false, string $default = null, array $autocomplete = null )
Asks for a value and validates the response.
Asks for a value and validates the response.
The validator receives the data to validate. It must return the
validated data when the data is valid and throw an exception
otherwise.
Parameters
- $output
- An Output instance
- $question
- The question to ask
- $validator
- A PHP callback
- $attempts
- Max number of times to ask before giving up (false by default, which means infinite)
- $default
- The default answer if none is given by the user
- $autocomplete
- List of values to autocomplete
Returns
mixed
Throws
Exception When any of the validators return an error
|
public
string
|
#
askHiddenResponseAndValidate( Symfony\Component\Console\Output\OutputInterface $output, string|array $question, callable $validator, integer|false $attempts = false, boolean $fallback = true )
Asks for a value, hide and validates the response.
Asks for a value, hide and validates the response.
The validator receives the data to validate. It must return the
validated data when the data is valid and throw an exception
otherwise.
Parameters
- $output
- An Output instance
- $question
- The question to ask
- $validator
- A PHP callback
- $attempts
- Max number of times to ask before giving up (false by default, which means infinite)
- $fallback
- In case the response can not be hidden, whether to fallback on non-hidden question or not
Returns
string The response
Throws
|
public
|
#
setInputStream( resource $stream )
Sets the input stream to read from when interacting with the user.
Sets the input stream to read from when interacting with the user.
This is mainly useful for testing purpose.
Parameters
|
public
resource|null
|
#
getInputStream( )
Returns the helper's input stream.
Returns the helper's input stream.
Returns
resource|null The input stream or null if the default STDIN is used
|
public
string
|
#
getName( )
Returns the canonical name of this helper.
Returns the canonical name of this helper.
Returns
string The canonical name
|