\app\framework\Component\Console\OutputConsoleSectionOutput

StreamOutput writes the output to a given stream.

Usage:

$output = new StreamOutput(fopen('php://stdout', 'w'));

As StreamOutput can use any stream, you can also use a file:

$output = new StreamOutput(fopen('/path/to/output.log', 'a', false));

Summary

Methods
Properties
Constants
__construct()
getStream()
write()
writeln()
setVerbosity()
getVerbosity()
isQuiet()
isVerbose()
isVeryVerbose()
isDebug()
setFormatter()
getFormatter()
setDecorated()
isDecorated()
clear()
overwrite()
getContent()
No public properties found
No constants found
doWrite()
hasColorSupport()
No protected properties found
N/A
popStreamContentUntilCurrentSection()
getDisplayLength()
$stream
$verbosity
$formatter
$content
$lines
$sections
$terminal
N/A

Properties

$stream

$stream : 

Type

$verbosity

$verbosity : 

Type

$formatter

$formatter : 

Type

$content

$content : 

Type

$lines

$lines : 

Type

$sections

$sections : 

Type

$terminal

$terminal : 

Type

Methods

__construct()

__construct(resource  $stream, array<mixed,\app\framework\Component\Console\Output\ConsoleSectionOutput>  $sections, \app\framework\Component\Console\Output\int  $verbosity, \app\framework\Component\Console\Output\bool  $decorated, \app\framework\Component\Console\Output\Formatter\OutputFormatterInterface  $formatter) 

Parameters

resource $stream

A stream resource

array<mixed,\app\framework\Component\Console\Output\ConsoleSectionOutput> $sections
\app\framework\Component\Console\Output\int $verbosity

The verbosity level (one of the VERBOSITY constants in OutputInterface)

\app\framework\Component\Console\Output\bool $decorated

Whether to decorate messages (null for auto-guessing)

\app\framework\Component\Console\Output\Formatter\OutputFormatterInterface $formatter

Output formatter instance (null to use default OutputFormatter)

getStream()

getStream() : resource

Gets the stream attached to this StreamOutput instance.

Returns

resource —

A stream resource

write()

write(string|array  $messages, boolean  $newline = false, integer  $options) 

Writes a message to the output.

Parameters

string|array $messages

The message as an array of lines or a single string

boolean $newline

Whether to add a newline

integer $options

A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL

writeln()

writeln(string|array  $messages, integer  $options = self::OUTPUT_NORMAL) 

Writes a message to the output and adds a newline at the end.

Parameters

string|array $messages

The message as an array of lines of a single string

integer $options

A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL

setVerbosity()

setVerbosity(integer  $level) 

Sets the verbosity of the output.

Parameters

integer $level

The level of verbosity (one of the VERBOSITY constants)

getVerbosity()

getVerbosity() : integer

Gets the current verbosity of the output.

Returns

integer —

The current level of verbosity (one of the VERBOSITY constants)

isQuiet()

isQuiet() : boolean

Returns whether verbosity is quiet (-q).

Returns

boolean —

true if verbosity is set to VERBOSITY_QUIET, false otherwise

isVerbose()

isVerbose() : boolean

Returns whether verbosity is verbose (-v).

Returns

boolean —

true if verbosity is set to VERBOSITY_VERBOSE, false otherwise

isVeryVerbose()

isVeryVerbose() : boolean

Returns whether verbosity is very verbose (-vv).

Returns

boolean —

true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise

isDebug()

isDebug() : boolean

Returns whether verbosity is debug (-vvv).

Returns

boolean —

true if verbosity is set to VERBOSITY_DEBUG, false otherwise

getFormatter()

getFormatter() 

{@inheritdoc}

setDecorated()

setDecorated(boolean  $decorated) 

Sets the decorated flag.

Parameters

boolean $decorated

Whether to decorate the messages

isDecorated()

isDecorated() 

clear()

clear(integer  $lines = null) 

Clears previous output for this section.

Parameters

integer $lines

Number of lines to clear. If null, then the entire output of this section is cleared

overwrite()

overwrite(array|string  $message) 

Overwrites the previous output with a new message.

Parameters

array|string $message

getContent()

getContent() 

doWrite()

doWrite(string  $message, boolean  $newline) 

Writes a message to the output.

Parameters

string $message

A message to write to the output

boolean $newline

Whether to add a newline or not

hasColorSupport()

hasColorSupport() : boolean

Returns true if the stream supports colorization.

Colorization is disabled if not supported by the stream:

  • Windows != 10.0.10586 without Ansicon, ConEmu or Mintty
  • non tty consoles

Returns

boolean —

true if the stream supports colorization, false otherwise

popStreamContentUntilCurrentSection()

popStreamContentUntilCurrentSection(\app\framework\Component\Console\Output\int  $numberOfLinesToClearFromCurrentSection) 

At initial stage, cursor is at the end of stream output. This method makes cursor crawl upwards until it hits current section. Then it erases content it crawled through. Optionally, it erases part of current section too.

Parameters

\app\framework\Component\Console\Output\int $numberOfLinesToClearFromCurrentSection

getDisplayLength()

getDisplayLength(\app\framework\Component\Console\Output\string  $text) 

Parameters

\app\framework\Component\Console\Output\string $text