SymfonyStyle
extends OutputStyle
in package
Output decorator helpers for the Symfony Style Guide.
Tags
Table of Contents
Constants
- MAX_LINE_LENGTH = 120
Properties
- $bufferedOutput : TrimmedBufferOutput
- $input : InputInterface
- $lineLength : int
- $output : OutputInterface
- $progressBar : ProgressBar
- $questionHelper : SymfonyQuestionHelper
Methods
- __construct() : mixed
- ask() : mixed
- Asks a question.
- askHidden() : mixed
- Asks a question with the user input hidden.
- askQuestion() : mixed
- block() : void
- Formats a message as a block of text.
- caution() : void
- Formats a caution admonition.
- choice() : mixed
- Asks a choice question.
- comment() : void
- Formats a command comment.
- confirm() : bool
- Asks for confirmation.
- createProgressBar() : ProgressBar
- createTable() : Table
- definitionList() : void
- Formats a list of key/value horizontally.
- error() : void
- Formats an error result bar.
- getErrorStyle() : self
- Returns a new instance which makes use of stderr if available.
- getFormatter() : OutputFormatterInterface
- Returns current output formatter instance.
- getVerbosity() : self::VERBOSITY_*
- Gets the current verbosity of the output.
- horizontalTable() : void
- Formats a horizontal table.
- info() : void
- Formats an info message.
- isDebug() : bool
- Returns whether verbosity is debug (-vvv).
- isDecorated() : bool
- Gets the decorated flag.
- isQuiet() : bool
- Returns whether verbosity is quiet (-q).
- isVerbose() : bool
- Returns whether verbosity is verbose (-v).
- isVeryVerbose() : bool
- Returns whether verbosity is very verbose (-vv).
- listing() : void
- Formats a list.
- newLine() : void
- Add newline(s).
- note() : void
- Formats a note admonition.
- progressAdvance() : void
- Advances the progress output X steps.
- progressFinish() : void
- Finishes the progress output.
- progressIterate() : iterable<TKey, TValue>
- progressStart() : void
- Starts the progress output.
- section() : void
- Formats a section title.
- setDecorated() : void
- Sets the decorated flag.
- setFormatter() : void
- setVerbosity() : void
- Sets the verbosity of the output.
- success() : void
- Formats a success result bar.
- table() : void
- Formats a table.
- text() : void
- Formats informational text.
- title() : void
- Formats a command title.
- warning() : void
- Formats an warning result bar.
- write() : void
- Writes a message to the output.
- writeln() : void
- Writes a message to the output and adds a newline at the end.
- getErrorOutput() : OutputInterface
- autoPrependBlock() : void
- autoPrependText() : void
- createBlock() : array<string|int, mixed>
- getProgressBar() : ProgressBar
- writeBuffer() : void
Constants
MAX_LINE_LENGTH
public
mixed
MAX_LINE_LENGTH
= 120
Properties
$bufferedOutput
private
TrimmedBufferOutput
$bufferedOutput
$input
private
InputInterface
$input
$lineLength
private
int
$lineLength
$output
private
OutputInterface
$output
$progressBar
private
ProgressBar
$progressBar
$questionHelper
private
SymfonyQuestionHelper
$questionHelper
Methods
__construct()
public
__construct(InputInterface $input, OutputInterface $output) : mixed
Parameters
- $input : InputInterface
- $output : OutputInterface
ask()
Asks a question.
public
ask(string $question[, string|null $default = null ][, callable|null $validator = null ]) : mixed
Parameters
- $question : string
- $default : string|null = null
- $validator : callable|null = null
askHidden()
Asks a question with the user input hidden.
public
askHidden(string $question[, callable|null $validator = null ]) : mixed
Parameters
- $question : string
- $validator : callable|null = null
askQuestion()
public
askQuestion(Question $question) : mixed
Parameters
- $question : Question
block()
Formats a message as a block of text.
public
block(string|array<string|int, mixed> $messages[, string|null $type = null ][, string|null $style = null ][, string $prefix = ' ' ][, bool $padding = false ][, bool $escape = true ]) : void
Parameters
- $messages : string|array<string|int, mixed>
- $type : string|null = null
- $style : string|null = null
- $prefix : string = ' '
- $padding : bool = false
- $escape : bool = true
caution()
Formats a caution admonition.
public
caution(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
choice()
Asks a choice question.
public
choice(string $question, array<string|int, mixed> $choices[, mixed $default = null ][, bool $multiSelect = false ]) : mixed
Parameters
- $question : string
- $choices : array<string|int, mixed>
- $default : mixed = null
- $multiSelect : bool = false
comment()
Formats a command comment.
public
comment(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
confirm()
Asks for confirmation.
public
confirm(string $question[, bool $default = true ]) : bool
Parameters
- $question : string
- $default : bool = true
Return values
boolcreateProgressBar()
public
createProgressBar([int $max = 0 ]) : ProgressBar
Parameters
- $max : int = 0
Return values
ProgressBarcreateTable()
public
createTable() : Table
Return values
TabledefinitionList()
Formats a list of key/value horizontally.
public
definitionList(string|array<string|int, mixed>|TableSeparator ...$list) : void
Each row can be one of:
- 'A title'
- ['key' => 'value']
- new TableSeparator()
Parameters
- $list : string|array<string|int, mixed>|TableSeparator
error()
Formats an error result bar.
public
error(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
getErrorStyle()
Returns a new instance which makes use of stderr if available.
public
getErrorStyle() : self
Return values
selfgetFormatter()
Returns current output formatter instance.
public
getFormatter() : OutputFormatterInterface
Return values
OutputFormatterInterfacegetVerbosity()
Gets the current verbosity of the output.
public
getVerbosity() : self::VERBOSITY_*
Return values
self::VERBOSITY_*horizontalTable()
Formats a horizontal table.
public
horizontalTable(array<string|int, mixed> $headers, array<string|int, mixed> $rows) : void
Parameters
- $headers : array<string|int, mixed>
- $rows : array<string|int, mixed>
info()
Formats an info message.
public
info(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
isDebug()
Returns whether verbosity is debug (-vvv).
public
isDebug() : bool
Return values
boolisDecorated()
Gets the decorated flag.
public
isDecorated() : bool
Return values
boolisQuiet()
Returns whether verbosity is quiet (-q).
public
isQuiet() : bool
Return values
boolisVerbose()
Returns whether verbosity is verbose (-v).
public
isVerbose() : bool
Return values
boolisVeryVerbose()
Returns whether verbosity is very verbose (-vv).
public
isVeryVerbose() : bool
Return values
boollisting()
Formats a list.
public
listing(array<string|int, mixed> $elements) : void
Parameters
- $elements : array<string|int, mixed>
newLine()
Add newline(s).
public
newLine([int $count = 1 ]) : void
Parameters
- $count : int = 1
note()
Formats a note admonition.
public
note(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
progressAdvance()
Advances the progress output X steps.
public
progressAdvance([int $step = 1 ]) : void
Parameters
- $step : int = 1
progressFinish()
Finishes the progress output.
public
progressFinish() : void
progressIterate()
public
progressIterate(iterable<TKey, TValue> $iterable[, int|null $max = null ]) : iterable<TKey, TValue>
Parameters
- $iterable : iterable<TKey, TValue>
- $max : int|null = null
-
Number of steps to complete the bar (0 if indeterminate), if null it will be inferred from $iterable
Tags
Return values
iterable<TKey, TValue>progressStart()
Starts the progress output.
public
progressStart([int $max = 0 ]) : void
Parameters
- $max : int = 0
section()
Formats a section title.
public
section(string $message) : void
Parameters
- $message : string
setDecorated()
Sets the decorated flag.
public
setDecorated(bool $decorated) : void
Parameters
- $decorated : bool
setFormatter()
public
setFormatter(OutputFormatterInterface $formatter) : void
Parameters
- $formatter : OutputFormatterInterface
setVerbosity()
Sets the verbosity of the output.
public
setVerbosity(int $level) : void
Parameters
- $level : int
success()
Formats a success result bar.
public
success(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
table()
Formats a table.
public
table(array<string|int, mixed> $headers, array<string|int, mixed> $rows) : void
Parameters
- $headers : array<string|int, mixed>
- $rows : array<string|int, mixed>
text()
Formats informational text.
public
text(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
title()
Formats a command title.
public
title(string $message) : void
Parameters
- $message : string
warning()
Formats an warning result bar.
public
warning(string|array<string|int, mixed> $message) : void
Parameters
- $message : string|array<string|int, mixed>
write()
Writes a message to the output.
public
write(string|iterable<string|int, mixed> $messages[, bool $newline = false ][, int $type = self::OUTPUT_NORMAL ]) : void
Parameters
- $messages : string|iterable<string|int, mixed>
- $newline : bool = false
-
Whether to add a newline
- $type : int = self::OUTPUT_NORMAL
writeln()
Writes a message to the output and adds a newline at the end.
public
writeln(string|iterable<string|int, mixed> $messages[, int $type = self::OUTPUT_NORMAL ]) : void
Parameters
- $messages : string|iterable<string|int, mixed>
- $type : int = self::OUTPUT_NORMAL
getErrorOutput()
protected
getErrorOutput() : OutputInterface
Return values
OutputInterfaceautoPrependBlock()
private
autoPrependBlock() : void
autoPrependText()
private
autoPrependText() : void
createBlock()
private
createBlock(iterable<string|int, mixed> $messages[, string|null $type = null ][, string|null $style = null ][, string $prefix = ' ' ][, bool $padding = false ][, bool $escape = false ]) : array<string|int, mixed>
Parameters
- $messages : iterable<string|int, mixed>
- $type : string|null = null
- $style : string|null = null
- $prefix : string = ' '
- $padding : bool = false
- $escape : bool = false
Return values
array<string|int, mixed>getProgressBar()
private
getProgressBar() : ProgressBar
Return values
ProgressBarwriteBuffer()
private
writeBuffer(string $message, bool $newLine, int $type) : void
Parameters
- $message : string
- $newLine : bool
- $type : int