Copied!

The QuestionHelper class provides helpers to interact with the user.

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

Asks a question to the user.

  • return mixed The user answer
  • throws \RuntimeException If there is no data to read in the input stream
public static disableStty() : void
 

Prevents usage of stty.

public static Symfony\Component\Console\Helper\Helper::formatMemory(int $memory) : string
public static Symfony\Component\Console\Helper\Helper::formatTime(int|float $secs, int $precision = 1) : string
public Symfony\Component\Console\Helper\Helper::getHelperSet() : ?Symfony\Component\Console\Helper\HelperSet
public getName() : string
public static Symfony\Component\Console\Helper\Helper::length(?string $string) : int
 

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

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

public static Symfony\Component\Console\Helper\Helper::removeDecoration(Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter, ?string $string) : string
public Symfony\Component\Console\Helper\Helper::setHelperSet(?Symfony\Component\Console\Helper\HelperSet $helperSet) : void
public static Symfony\Component\Console\Helper\Helper::substr(?string $string, int $from, ?int $length = NULL) : string
 

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

public static Symfony\Component\Console\Helper\Helper::width(?string $string) : int
 

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

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

Properties
protected ?Symfony\Component\Console\Helper\HelperSet Symfony\Component\Console\Helper\Helper::$helperSet = NULL
Methods
protected formatChoiceQuestionChoices(Symfony\Component\Console\Question\ChoiceQuestion $question, string $tag) : array
 
  • return string[]
protected writeError(Symfony\Component\Console\Output\OutputInterface $output, Exception $error) : void
 

Outputs an error message.

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

Outputs the question prompt.

Properties
private static bool $stdinIsInteractive
private static bool $stty = true
Methods
private autocomplete(Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Question\Question $question, $inputStream, callable $autocomplete) : string
 

Autocompletes a question.

  • param resource $inputStream
private cloneInputStream( $inputStream)
 

Clones an input stream in order to act on one instance of the same stream without affecting the other instance.

  • param resource $inputStream The handler resource
  • return resource|null The cloned resource, null in case it could not be cloned
private doAsk( $inputStream, Symfony\Component\Console\Output\OutputInterface $output, Symfony\Component\Console\Question\Question $question) : ?mixed
 

Asks the question to the user.

  • param resource $inputStream
  • throws \RuntimeException In case the fallback is deactivated and the response cannot be hidden
private getDefaultAnswer(Symfony\Component\Console\Question\Question $question) : ?mixed
private getHiddenResponse(Symfony\Component\Console\Output\OutputInterface $output, $inputStream, bool $trimmable = true) : string
 

Gets a hidden response from user.

  • param resource $inputStream The handler resource
  • param bool $trimmable Is the answer trimmable
  • throws \RuntimeException In case the fallback is deactivated and the response cannot be hidden
private isInteractiveInput( $inputStream) : bool
private mostRecentlyEnteredValue(string $entered) : string
private readInput( $inputStream, Symfony\Component\Console\Question\Question $question) : string|false
 

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

  • param resource $inputStream The handler resource
  • param \Question $question The question being asked
private resetIOCodepage(int $cp, string|false $input) : string|false
 

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

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

Validates an attempt.

  • param callable $interviewer A callable that will ask for a question and return the result
  • throws \Exception In case the max number of attempts has been reached and no valid response has been given
Properties
private static bool $stdinIsInteractive
private static bool $stty = true
Methods
public static disableStty() : void
 

Prevents usage of stty.

public static Symfony\Component\Console\Helper\Helper::formatMemory(int $memory) : string
public static Symfony\Component\Console\Helper\Helper::formatTime(int|float $secs, int $precision = 1) : string
public static Symfony\Component\Console\Helper\Helper::length(?string $string) : int
 

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

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

public static Symfony\Component\Console\Helper\Helper::removeDecoration(Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter, ?string $string) : string
public static Symfony\Component\Console\Helper\Helper::substr(?string $string, int $from, ?int $length = NULL) : string
 

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

public static Symfony\Component\Console\Helper\Helper::width(?string $string) : int
 

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

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

© 2024 Bruce Wells
Search Namespaces \ Classes
Configuration