Skip to content

Latest commit

 

History

History
646 lines (234 loc) · 7.14 KB

ConsoleSectionOutput.md

File metadata and controls

646 lines (234 loc) · 7.14 KB

ConsoleSectionOutput

StreamOutput writes the output to a given stream.

Properties

content

private $content

lines

private $lines

sections

private $sections

terminal

private $terminal

Methods

__construct

public __construct(resource $stream, \Symfony\Component\Console\Output\ConsoleSectionOutput[]& $sections, int $verbosity, bool $decorated, \Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter): mixed

Parameters:

Parameter Type Description
$stream resource
$sections \Symfony\Component\Console\Output\ConsoleSectionOutput[]
$verbosity int The verbosity level (one of the VERBOSITY constants in OutputInterface)
$decorated bool Whether to decorate messages (null for auto-guessing)
$formatter \Symfony\Component\Console\Formatter\OutputFormatterInterface Output formatter instance (null to use default OutputFormatter)

clear

Clears previous output for this section.

public clear(int $lines = null): mixed

Parameters:

Parameter Type Description
$lines int Number of lines to clear. If null, then the entire output of this section is cleared

overwrite

Overwrites the previous output with a new message.

public overwrite(array|string $message): mixed

Parameters:

Parameter Type Description
$message array|string

getContent

public getContent(): string

doWrite

Writes a message to the output.

protected doWrite(string $message, bool $newline): mixed

Parameters:

Parameter Type Description
$message string
$newline bool

popStreamContentUntilCurrentSection

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.

private popStreamContentUntilCurrentSection(int $numberOfLinesToClearFromCurrentSection): string

Parameters:

Parameter Type Description
$numberOfLinesToClearFromCurrentSection int

getDisplayLength

private getDisplayLength(string $text): int

Parameters:

Parameter Type Description
$text string

Inherited methods

__construct

public __construct(int|null $verbosity = self::VERBOSITY_NORMAL, bool $decorated = false, \Symfony\Component\Console\Formatter\OutputFormatterInterface|null $formatter = null): mixed

Parameters:

Parameter Type Description
$verbosity int|null The verbosity level (one of the VERBOSITY constants in OutputInterface)
$decorated bool Whether to decorate messages
$formatter \Symfony\Component\Console\Formatter\OutputFormatterInterface|null Output formatter instance (null to use default OutputFormatter)

getStream

Gets the stream attached to this StreamOutput instance.

public getStream(): resource

doWrite

Writes a message to the output.

protected doWrite(string $message, bool $newline): mixed
  • This method is abstract.

Parameters:

Parameter Type Description
$message string
$newline bool

hasColorSupport

Returns true if the stream supports colorization.

protected hasColorSupport(): bool

Colorization is disabled if not supported by the stream:

This is tricky on Windows, because Cygwin, Msys2 etc emulate pseudo terminals via named pipes, so we can only check the environment.

Reference: Composer\XdebugHandler\Process::supportsColor https://github.com/composer/xdebug-handler

Return Value:

true if the stream supports colorization, false otherwise


setFormatter

public setFormatter(\Symfony\Component\Console\Formatter\OutputFormatterInterface $formatter): mixed

Parameters:

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

getFormatter

Returns current output formatter instance.

public getFormatter(): \Symfony\Component\Console\Formatter\OutputFormatterInterface

setDecorated

Sets the decorated flag.

public setDecorated(bool $decorated): mixed

Parameters:

Parameter Type Description
$decorated bool

isDecorated

Gets the decorated flag.

public isDecorated(): bool

setVerbosity

Sets the verbosity of the output.

public setVerbosity(int $level): mixed

Parameters:

Parameter Type Description
$level int

getVerbosity

Gets the current verbosity of the output.

public getVerbosity(): int

isQuiet

Returns whether verbosity is quiet (-q).

public isQuiet(): bool

isVerbose

Returns whether verbosity is verbose (-v).

public isVerbose(): bool

isVeryVerbose

Returns whether verbosity is very verbose (-vv).

public isVeryVerbose(): bool

isDebug

Returns whether verbosity is debug (-vvv).

public isDebug(): bool

writeln

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

public writeln(mixed $messages, int $options = self::OUTPUT_NORMAL): mixed

Parameters:

Parameter Type Description
$messages mixed The message as an iterable of strings or a single string
$options int A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL

write

Writes a message to the output.

public write(mixed $messages, bool $newline = false, int $options = self::OUTPUT_NORMAL): mixed

Parameters:

Parameter Type Description
$messages mixed The message as an iterable of strings or a single string
$newline bool Whether to add a newline
$options int A bitmask of options (one of the OUTPUT or VERBOSITY constants), 0 is considered the same as self::OUTPUT_NORMAL | self::VERBOSITY_NORMAL