SymfonyQuestionHelper
extends QuestionHelper
in package
Symfony Style Guide compliant question helper.
Tags
Table of Contents
Properties
- $helperSet : mixed
- $inputStream : resource|null
- $stdinIsInteractive : bool
- $stty : bool
Methods
- ask() : mixed
- Asks a question to the user.
- disableStty() : void
- Prevents usage of stty.
- formatMemory() : string
- formatTime() : string
- getHelperSet() : HelperSet|null
- Gets the helper set associated with this helper.
- getName() : string
- Returns the canonical name of this helper.
- length() : int
- Returns the length of a string, using mb_strlen if it is available.
- removeDecoration() : string
- setHelperSet() : void
- Sets the helper set associated with this helper.
- substr() : string
- Returns the subset of a string, using mb_substr if it is available.
- width() : int
- Returns the width of a string, using mb_strwidth if it is available.
- formatChoiceQuestionChoices() : array<string|int, string>
- writeError() : void
- Outputs an error message.
- writePrompt() : void
- Outputs the question prompt.
- autocomplete() : string
- Autocompletes a question.
- cloneInputStream() : resource|null
- Clones an input stream in order to act on one instance of the same stream without affecting the other instance.
- doAsk() : mixed
- Asks the question to the user.
- getDefaultAnswer() : mixed
- getEofShortcut() : string
- getHiddenResponse() : string
- Gets a hidden response from user.
- isInteractiveInput() : bool
- mostRecentlyEnteredValue() : string
- readInput() : string|false
- Reads one or more lines of input and returns what is read.
- resetIOCodepage() : string|false
- Sets console I/O to the specified code page and converts the user input.
- setIOCodepage() : int
- validateAttempts() : mixed
- Validates an attempt.
Properties
$helperSet
protected
mixed
$helperSet
$inputStream
private
resource|null
$inputStream
$stdinIsInteractive
private
static bool
$stdinIsInteractive
$stty
private
static bool
$stty
= true
Methods
ask()
Asks a question to the user.
public
ask(InputInterface $input, OutputInterface $output, Question $question) : mixed
Parameters
- $input : InputInterface
- $output : OutputInterface
- $question : Question
Tags
Return values
mixed —The user answer
disableStty()
Prevents usage of stty.
public
static disableStty() : void
formatMemory()
public
static formatMemory(int $memory) : string
Parameters
- $memory : int
Return values
stringformatTime()
public
static formatTime(int|float $secs[, int $precision = 1 ]) : string
Parameters
- $secs : int|float
- $precision : int = 1
Return values
stringgetHelperSet()
Gets the helper set associated with this helper.
public
getHelperSet() : HelperSet|null
Return values
HelperSet|nullgetName()
Returns the canonical name of this helper.
public
getName() : string
Return values
stringlength()
Returns the length of a string, using mb_strlen if it is available.
public
static length(string|null $string) : int
The length is related to how many bytes the string will use.
Parameters
- $string : string|null
Return values
intremoveDecoration()
public
static removeDecoration(OutputFormatterInterface $formatter, string|null $string) : string
Parameters
- $formatter : OutputFormatterInterface
- $string : string|null
Return values
stringsetHelperSet()
Sets the helper set associated with this helper.
public
setHelperSet([HelperSet|null $helperSet = null ]) : void
Parameters
- $helperSet : HelperSet|null = null
substr()
Returns the subset of a string, using mb_substr if it is available.
public
static substr(string|null $string, int $from[, int|null $length = null ]) : string
Parameters
- $string : string|null
- $from : int
- $length : int|null = null
Return values
stringwidth()
Returns the width of a string, using mb_strwidth if it is available.
public
static width(string|null $string) : int
The width is how many characters positions the string will use.
Parameters
- $string : string|null
Return values
intformatChoiceQuestionChoices()
protected
formatChoiceQuestionChoices(ChoiceQuestion $question, string $tag) : array<string|int, string>
Parameters
- $question : ChoiceQuestion
- $tag : string
Return values
array<string|int, string>writeError()
Outputs an error message.
protected
writeError(OutputInterface $output, Exception $error) : void
Parameters
- $output : OutputInterface
- $error : Exception
writePrompt()
Outputs the question prompt.
protected
writePrompt(OutputInterface $output, Question $question) : void
Parameters
- $output : OutputInterface
- $question : Question
autocomplete()
Autocompletes a question.
private
autocomplete(OutputInterface $output, Question $question, resource $inputStream, callable $autocomplete) : string
Parameters
- $output : OutputInterface
- $question : Question
- $inputStream : resource
- $autocomplete : callable
Return values
stringcloneInputStream()
Clones an input stream in order to act on one instance of the same stream without affecting the other instance.
private
cloneInputStream(resource $inputStream) : resource|null
Parameters
- $inputStream : resource
-
The handler resource
Return values
resource|null —The cloned resource, null in case it could not be cloned
doAsk()
Asks the question to the user.
private
doAsk(OutputInterface $output, Question $question) : mixed
Parameters
- $output : OutputInterface
- $question : Question
Tags
getDefaultAnswer()
private
getDefaultAnswer(Question $question) : mixed
Parameters
- $question : Question
getEofShortcut()
private
getEofShortcut() : string
Return values
stringgetHiddenResponse()
Gets a hidden response from user.
private
getHiddenResponse(OutputInterface $output, resource $inputStream[, bool $trimmable = true ]) : string
Parameters
- $output : OutputInterface
- $inputStream : resource
-
The handler resource
- $trimmable : bool = true
-
Is the answer trimmable
Tags
Return values
stringisInteractiveInput()
private
isInteractiveInput(mixed $inputStream) : bool
Parameters
- $inputStream : mixed
Return values
boolmostRecentlyEnteredValue()
private
mostRecentlyEnteredValue(string $entered) : string
Parameters
- $entered : string
Return values
stringreadInput()
Reads one or more lines of input and returns what is read.
private
readInput(resource $inputStream, Question $question) : string|false
Parameters
- $inputStream : resource
-
The handler resource
- $question : Question
-
The question being asked
Return values
string|falseresetIOCodepage()
Sets console I/O to the specified code page and converts the user input.
private
resetIOCodepage(int $cp, string|false $input) : string|false
Parameters
- $cp : int
- $input : string|false
Return values
string|falsesetIOCodepage()
private
setIOCodepage() : int
Return values
intvalidateAttempts()
Validates an attempt.
private
validateAttempts(callable $interviewer, OutputInterface $output, Question $question) : mixed
Parameters
- $interviewer : callable
-
A callable that will ask for a question and return the result
- $output : OutputInterface
- $question : Question