Documentation

ShellOutput extends ConsoleOutput
in package

A ConsoleOutput subclass specifically for Psy Shell output.

Table of Contents

NUMBER_LINES  = 128
$formatter  : mixed
$pager  : mixed
$paging  : mixed
$stderr  : mixed
$stream  : mixed
$verbosity  : mixed
__construct()  : mixed
Construct a ShellOutput instance.
doWrite()  : mixed
Writes a message to the output.
getErrorOutput()  : OutputInterface
Gets the OutputInterface for errors.
getFormatter()  : OutputFormatterInterface
Returns current output formatter instance.
getStream()  : resource
Gets the stream attached to this StreamOutput instance.
getVerbosity()  : int
Gets the current verbosity of the output.
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).
page()  : mixed
Page multiple lines of output.
setDecorated()  : mixed
Sets the decorated flag.
setErrorOutput()  : mixed
setFormatter()  : mixed
setVerbosity()  : mixed
Sets the verbosity of the output.
startPaging()  : mixed
Start sending output to the output pager.
stopPaging()  : mixed
Stop paging output and flush the output pager.
write()  : mixed
Writes a message to the output.
writeln()  : mixed
Writes a message to the output and adds a newline at the end.
hasColorSupport()  : bool
Returns true if the stream supports colorization.
hasStderrSupport()  : bool
Returns true if current environment supports writing console output to STDERR.
hasStdoutSupport()  : bool
Returns true if current environment supports writing console output to STDOUT.
closePager()  : mixed
Flush and close the output pager.
initFormatters()  : mixed
Initialize output formatter styles.
isRunningOS400()  : bool
Checks if current executing environment is IBM iSeries (OS400), which doesn't properly convert character-encodings between ASCII to EBCDIC.
openErrorStream()  : resource
openOutputStream()  : resource

Constants

Properties

$formatter

private mixed $formatter

$verbosity

private mixed $verbosity

Methods

__construct()

Construct a ShellOutput instance.

public __construct([mixed $verbosity = self::VERBOSITY_NORMAL ][, bool $decorated = null ][, OutputFormatterInterface $formatter = null ][, null|string|OutputPager $pager = null ]) : mixed
Parameters
$verbosity : mixed = self::VERBOSITY_NORMAL

(default: self::VERBOSITY_NORMAL)

$decorated : bool = null

(default: null)

$formatter : OutputFormatterInterface = null

(default: null)

$pager : null|string|OutputPager = null

(default: null)

Return values
mixed

doWrite()

Writes a message to the output.

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

Handles paged output, or writes directly to the output stream.

Parameters
$message : string

A message to write to the output

$newline : bool

Whether to add a newline or not

Return values
mixed

getStream()

Gets the stream attached to this StreamOutput instance.

public getStream() : resource
Return values
resource

A stream resource

getVerbosity()

Gets the current verbosity of the output.

public getVerbosity() : int
Return values
int

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

isDebug()

Returns whether verbosity is debug (-vvv).

public isDebug() : bool
Return values
bool

true if verbosity is set to VERBOSITY_DEBUG, false otherwise

isDecorated()

Gets the decorated flag.

public isDecorated() : bool
Return values
bool

true if the output will decorate messages, false otherwise

isQuiet()

Returns whether verbosity is quiet (-q).

public isQuiet() : bool
Return values
bool

true if verbosity is set to VERBOSITY_QUIET, false otherwise

isVerbose()

Returns whether verbosity is verbose (-v).

public isVerbose() : bool
Return values
bool

true if verbosity is set to VERBOSITY_VERBOSE, false otherwise

isVeryVerbose()

Returns whether verbosity is very verbose (-vv).

public isVeryVerbose() : bool
Return values
bool

true if verbosity is set to VERBOSITY_VERY_VERBOSE, false otherwise

page()

Page multiple lines of output.

public page(string|array<string|int, mixed>|Closure $messages, int $type) : mixed

The output pager is started

If $messages is callable, it will be called, passing this output instance for rendering. Otherwise, all passed $messages are paged to output.

Upon completion, the output pager is flushed.

Parameters
$messages : string|array<string|int, mixed>|Closure

A string, array of strings or a callback

$type : int

(default: 0)

Return values
mixed

setDecorated()

Sets the decorated flag.

public setDecorated(mixed $decorated) : mixed
Parameters
$decorated : mixed

Whether to decorate the messages

Return values
mixed

setVerbosity()

Sets the verbosity of the output.

public setVerbosity(mixed $level) : mixed
Parameters
$level : mixed

The level of verbosity (one of the VERBOSITY constants)

Return values
mixed

startPaging()

Start sending output to the output pager.

public startPaging() : mixed
Return values
mixed

stopPaging()

Stop paging output and flush the output pager.

public stopPaging() : mixed
Return values
mixed

write()

Writes a message to the output.

public write(string|array<string|int, mixed> $messages[, bool $newline = false ], int $type) : mixed

Optionally, pass $type | self::NUMBER_LINES as the $type parameter to number the lines of output.

Parameters
$messages : string|array<string|int, mixed>

The message as an array of lines or a single string

$newline : bool = false

Whether to add a newline or not

$type : int

The type of output

Tags
throws
InvalidArgumentException

When unknown output type is given

Return values
mixed

writeln()

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

public writeln(mixed $messages[, mixed $options = self::OUTPUT_NORMAL ]) : mixed
Parameters
$messages : mixed

The message as an array of strings or a single string

$options : mixed = self::OUTPUT_NORMAL

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

Return values
mixed

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 values
bool

true if the stream supports colorization, false otherwise

hasStderrSupport()

Returns true if current environment supports writing console output to STDERR.

protected hasStderrSupport() : bool
Return values
bool

hasStdoutSupport()

Returns true if current environment supports writing console output to STDOUT.

protected hasStdoutSupport() : bool
Return values
bool

closePager()

Flush and close the output pager.

private closePager() : mixed
Return values
mixed

initFormatters()

Initialize output formatter styles.

private initFormatters() : mixed
Return values
mixed

isRunningOS400()

Checks if current executing environment is IBM iSeries (OS400), which doesn't properly convert character-encodings between ASCII to EBCDIC.

private isRunningOS400() : bool
Return values
bool

openErrorStream()

private openErrorStream() : resource
Return values
resource

openOutputStream()

private openOutputStream() : resource
Return values
resource

Search results