Skip to content

Latest commit

 

History

History
820 lines (324 loc) · 10.8 KB

SymfonyQuestionHelper.md

File metadata and controls

820 lines (324 loc) · 10.8 KB

SymfonyQuestionHelper

Symfony Style Guide compliant question helper.

Methods

writePrompt

Outputs the question prompt.

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

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question

writeError

Outputs an error message.

protected writeError(\Symfony\Component\Console\Output\OutputInterface $output, \Exception $error): mixed

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$error \Exception

getEofShortcut

private getEofShortcut(): string

Inherited methods

ask

Asks a question to the user.

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

Parameters:

Parameter Type Description
$input \Symfony\Component\Console\Input\InputInterface
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question

Return Value:

The user answer


getName

{@inheritdoc}

public getName(): mixed

disableStty

Prevents usage of stty.

public static disableStty(): mixed
  • This method is static.

doAsk

Asks the question to the user.

private doAsk(\Symfony\Component\Console\Output\OutputInterface $output, \Symfony\Component\Console\Question\Question $question): mixed

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question

getDefaultAnswer

private getDefaultAnswer(\Symfony\Component\Console\Question\Question $question): mixed

Parameters:

Parameter Type Description
$question \Symfony\Component\Console\Question\Question

writePrompt

Outputs the question prompt.

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

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question

formatChoiceQuestionChoices

protected formatChoiceQuestionChoices(\Symfony\Component\Console\Question\ChoiceQuestion $question, string $tag): string[]

Parameters:

Parameter Type Description
$question \Symfony\Component\Console\Question\ChoiceQuestion
$tag string

writeError

Outputs an error message.

protected writeError(\Symfony\Component\Console\Output\OutputInterface $output, \Exception $error): mixed

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$error \Exception

autocomplete

Autocompletes a question.

private autocomplete(\Symfony\Component\Console\Output\OutputInterface $output, \Symfony\Component\Console\Question\Question $question, resource $inputStream, callable $autocomplete): string

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question
$inputStream resource
$autocomplete callable

mostRecentlyEnteredValue

private mostRecentlyEnteredValue(string $entered): string

Parameters:

Parameter Type Description
$entered string

getHiddenResponse

Gets a hidden response from user.

private getHiddenResponse(\Symfony\Component\Console\Output\OutputInterface $output, resource $inputStream, bool $trimmable = true): string

Parameters:

Parameter Type Description
$output \Symfony\Component\Console\Output\OutputInterface
$inputStream resource The handler resource
$trimmable bool Is the answer trimmable

validateAttempts

Validates an attempt.

private validateAttempts(callable $interviewer, \Symfony\Component\Console\Output\OutputInterface $output, \Symfony\Component\Console\Question\Question $question): mixed

Parameters:

Parameter Type Description
$interviewer callable A callable that will ask for a question and return the result
$output \Symfony\Component\Console\Output\OutputInterface
$question \Symfony\Component\Console\Question\Question

Return Value:

The validated response


isInteractiveInput

private isInteractiveInput(mixed $inputStream): bool

Parameters:

Parameter Type Description
$inputStream mixed

readInput

Reads one or more lines of input and returns what is read.

private readInput(resource $inputStream, \Symfony\Component\Console\Question\Question $question): string|false

Parameters:

Parameter Type Description
$inputStream resource The handler resource
$question \Symfony\Component\Console\Question\Question The question being asked

Return Value:

The input received, false in case input could not be read


setIOCodepage

Sets console I/O to the host code page.

private setIOCodepage(): int

Return Value:

Previous code page in IBM/EBCDIC format


resetIOCodepage

Sets console I/O to the specified code page and converts the user input.

private resetIOCodepage(int $cp, string|false $input): string|false

Parameters:

Parameter Type Description
$cp int
$input string|false

cloneInputStream

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:

Parameter Type Description
$inputStream resource The handler resource

Return Value:

The cloned resource, null in case it could not be cloned


setHelperSet

Sets the helper set associated with this helper.

public setHelperSet(\Symfony\Component\Console\Helper\HelperSet $helperSet = null): mixed

Parameters:

Parameter Type Description
$helperSet \Symfony\Component\Console\Helper\HelperSet

getHelperSet

Gets the helper set associated with this helper.

public getHelperSet(): \Symfony\Component\Console\Helper\HelperSet|null

strlen

Returns the length of a string, using mb_strwidth if it is available.

public static strlen(?string $string): int
  • This method is static.

  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.

Parameters:

Parameter Type Description
$string ?string

width

Returns the width of a string, using mb_strwidth if it is available.

public static width(?string $string): int

The width is how many characters positions the string will use.

  • This method is static.

Parameters:

Parameter Type Description
$string ?string

length

Returns the length of a string, using mb_strlen if it is available.

public static length(?string $string): int

The length is related to how many bytes the string will use.

  • This method is static.

Parameters:

Parameter Type Description
$string ?string

substr

Returns the subset of a string, using mb_substr if it is available.

public static substr(?string $string, int $from, int $length = null): string
  • This method is static.

Parameters:

Parameter Type Description
$string ?string
$from int
$length int

formatTime

public static formatTime(mixed $secs): mixed
  • This method is static.

Parameters:

Parameter Type Description
$secs mixed

formatMemory

public static formatMemory(int $memory): mixed
  • This method is static.

Parameters:

Parameter Type Description
$memory int

strlenWithoutDecoration

public static strlenWithoutDecoration(\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter, ?string $string): mixed
  • This method is static.

  • Warning: this method is deprecated. This means that this method will likely be removed in a future version.

Parameters:

Parameter Type Description
$formatter \Symfony\Component\Console\Formatter\OutputFormatterInterface
$string ?string

removeDecoration

public static removeDecoration(\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter, ?string $string): mixed
  • This method is static.

Parameters:

Parameter Type Description
$formatter \Symfony\Component\Console\Formatter\OutputFormatterInterface
$string ?string