Documentation

Dumper extends CliDumper
in package

A PsySH-specialized CliDumper.

Table of Contents

DUMP_COMMA_SEPARATOR  = 4
DUMP_LIGHT_ARRAY  = 1
DUMP_STRING_LENGTH  = 2
DUMP_TRAILING_COMMA  = 8
$defaultColors  : mixed
$defaultOutput  : mixed
$collapseNextHash  : mixed
$colors  : mixed
$controlCharsMap  : mixed
$controlCharsRx  : mixed
$decimalPoint  : mixed
$expandNextHash  : mixed
$flags  : mixed
$indentPad  : mixed
$line  : mixed
$lineDumper  : mixed
$maxStringWidth  : mixed
$onlyControlCharsRx  : mixed
$outputStream  : mixed
$styles  : mixed
$charset  : mixed
$forceArrayIndexes  : mixed
$formatter  : mixed
__construct()  : mixed
dump()  : string|null
Dumps a Data object.
dumpScalar()  : mixed
{@inheritdoc}
dumpString()  : mixed
{@inheritdoc}
enterHash()  : mixed
{@inheritdoc}
leaveHash()  : mixed
{@inheritdoc}
setCharset()  : string
Sets the default character encoding to use for non-UTF8 strings.
setColors()  : mixed
Enables/disables colored output.
setIndentPad()  : string
Sets the indentation pad string.
setMaxStringWidth()  : mixed
Sets the maximum number of characters per line for dumped strings.
setOutput()  : callable|resource|string
Sets the output destination of the dumps.
setStyles()  : mixed
Configures styles.
dumpEllipsis()  : mixed
Dumps an ellipsis for cut children.
dumpKey()  : mixed
Dumps a key in a hash structure.
dumpLine()  : mixed
Dumps the current line.
echoLine()  : mixed
Generic line dumper callback.
endValue()  : mixed
style()  : string
Decorates a value with some style.
supportsColors()  : bool
utf8Encode()  : string|null
Converts a non-UTF-8 string to UTF-8.
hasColorSupport()  : bool
Returns true if the stream supports colorization.
isWindowsTrueColor()  : bool
Returns true if the Windows terminal supports true color.

Constants

Properties

$defaultColors

public static mixed $defaultColors

$defaultOutput

public static mixed $defaultOutput = 'php://output'

$collapseNextHash

protected mixed $collapseNextHash = false

$controlCharsMap

protected static mixed $controlCharsMap = ["" => '\0', " " => '\t', " " => '\n', " " => '\v', " " => '\f', " " => '\r', "" => '\e']

$controlCharsRx

protected static mixed $controlCharsRx = '/([\x00-\x1F\x7F]+)/'

$expandNextHash

protected mixed $expandNextHash = false

$maxStringWidth

protected mixed $maxStringWidth = 0

$onlyControlCharsRx

protected static mixed $onlyControlCharsRx = '/^[\x00-\x1F\x7F]+$/'

$styles

protected mixed $styles = [ // See http://en.wikipedia.org/wiki/ANSI_escape_code#graphics 'default' => '0;38;5;208', 'num' => '1;38;5;38', 'const' => '1;38;5;208', 'str' => '1;38;5;113', 'note' => '38;5;38', 'ref' => '38;5;247', 'public' => '', 'protected' => '', 'private' => '', 'meta' => '38;5;170', 'key' => '38;5;113', 'index' => '38;5;38', ]

$forceArrayIndexes

private mixed $forceArrayIndexes

$formatter

private mixed $formatter

Methods

__construct()

public __construct(OutputFormatter $formatter[, mixed $forceArrayIndexes = false ]) : mixed
Parameters
$formatter : OutputFormatter
$forceArrayIndexes : mixed = false
Return values
mixed —

dump()

Dumps a Data object.

public dump(Data $data[, callable|resource|string|true|null $output = null ]) : string|null
Parameters
$data : Data

A Data object

$output : callable|resource|string|true|null = null

A line dumper callable, an opened stream, an output path or true to return the dump

Return values
string|null —

The dump as string when $output is true

dumpScalar()

{@inheritdoc}

public dumpScalar(Cursor $cursor, mixed $type, mixed $value) : mixed
Parameters
$cursor : Cursor
$type : mixed
$value : mixed
Return values
mixed —

dumpString()

{@inheritdoc}

public dumpString(Cursor $cursor, mixed $str, mixed $bin, mixed $cut) : mixed
Parameters
$cursor : Cursor
$str : mixed
$bin : mixed
$cut : mixed
Return values
mixed —

enterHash()

{@inheritdoc}

public enterHash(Cursor $cursor, mixed $type, mixed $class, mixed $hasChild) : mixed
Parameters
$cursor : Cursor
$type : mixed
$class : mixed
$hasChild : mixed
Return values
mixed —

leaveHash()

{@inheritdoc}

public leaveHash(Cursor $cursor, mixed $type, mixed $class, mixed $hasChild, mixed $cut) : mixed
Parameters
$cursor : Cursor
$type : mixed
$class : mixed
$hasChild : mixed
$cut : mixed
Return values
mixed —

setCharset()

Sets the default character encoding to use for non-UTF8 strings.

public setCharset(string $charset) : string
Parameters
$charset : string

The default character encoding to use for non-UTF8 strings

Return values
string —

The previous charset

setColors()

Enables/disables colored output.

public setColors(bool $colors) : mixed
Parameters
$colors : bool
Return values
mixed —

setIndentPad()

Sets the indentation pad string.

public setIndentPad(string $pad) : string
Parameters
$pad : string

A string that will be prepended to dumped lines, repeated by nesting level

Return values
string —

The previous indent pad

setMaxStringWidth()

Sets the maximum number of characters per line for dumped strings.

public setMaxStringWidth(int $maxStringWidth) : mixed
Parameters
$maxStringWidth : int
Return values
mixed —

setOutput()

Sets the output destination of the dumps.

public setOutput(callable|resource|string $output) : callable|resource|string
Parameters
$output : callable|resource|string

A line dumper callable, an opened stream or an output path

Return values
callable|resource|string —

The previous output destination

setStyles()

Configures styles.

public setStyles(array<string|int, mixed> $styles) : mixed
Parameters
$styles : array<string|int, mixed>

A map of style names to style definitions

Return values
mixed —

dumpEllipsis()

Dumps an ellipsis for cut children.

protected dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut) : mixed
Parameters
$cursor : Cursor

The Cursor position in the dump

$hasChild : bool

When the dump of the hash has child item

$cut : int

The number of items the hash has been cut by

Return values
mixed —

dumpKey()

Dumps a key in a hash structure.

protected dumpKey(Cursor $cursor) : mixed
Parameters
$cursor : Cursor

The Cursor position in the dump

Return values
mixed —

dumpLine()

Dumps the current line.

protected dumpLine(mixed $depth[, mixed $endOfValue = false ]) : mixed
Parameters
$depth : mixed

The recursive depth in the dumped structure for the line being dumped, or -1 to signal the end-of-dump to the line dumper callable

$endOfValue : mixed = false
Return values
mixed —

echoLine()

Generic line dumper callback.

protected echoLine(string $line, int $depth, string $indentPad) : mixed
Parameters
$line : string

The line to write

$depth : int

The recursive depth in the dumped structure

$indentPad : string

The line indent pad

Return values
mixed —

endValue()

protected endValue(Cursor $cursor) : mixed
Parameters
$cursor : Cursor
Return values
mixed —

style()

Decorates a value with some style.

protected style(mixed $style, mixed $value[, mixed $attr = [] ]) : string
Parameters
$style : mixed

The type of style being applied

$value : mixed

The value being styled

$attr : mixed = []

Optional context information

Return values
string —

The value with style decoration

supportsColors()

protected supportsColors() : bool
Return values
bool —

Tells if the current output stream supports ANSI colors or not

utf8Encode()

Converts a non-UTF-8 string to UTF-8.

protected utf8Encode(string|null $s) : string|null
Parameters
$s : string|null

The non-UTF-8 string to convert

Return values
string|null —

The string converted to UTF-8

hasColorSupport()

Returns true if the stream supports colorization.

private hasColorSupport(mixed $stream) : bool

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

Parameters
$stream : mixed

A CLI output stream

Return values
bool —

isWindowsTrueColor()

Returns true if the Windows terminal supports true color.

private isWindowsTrueColor() : bool

Note that this does not check an output stream, but relies on environment variables from known implementations, or a PHP and Windows version that supports true color.

Return values
bool —

Search results