CliDumper
extends AbstractDumper
in package
CliDumper dumps variables for command line output.
Tags
Table of Contents
Constants
- DUMP_COMMA_SEPARATOR = 4
- DUMP_LIGHT_ARRAY = 1
- DUMP_STRING_LENGTH = 2
- DUMP_TRAILING_COMMA = 8
Properties
- $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
- $outputStream : mixed
- $styles : mixed
- $charset : string
- $displayOptions : array<string|int, mixed>
- $handlesHrefGracefully : bool
Methods
- __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.
- setDisplayOptions() : mixed
- Configures display options.
- 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.
- getSourceLink() : mixed
- hasColorSupport() : bool
- Returns true if the stream supports colorization.
- isWindowsTrueColor() : bool
- Returns true if the Windows terminal supports true color.
Constants
DUMP_COMMA_SEPARATOR
public
mixed
DUMP_COMMA_SEPARATOR
= 4
DUMP_LIGHT_ARRAY
public
mixed
DUMP_LIGHT_ARRAY
= 1
DUMP_STRING_LENGTH
public
mixed
DUMP_STRING_LENGTH
= 2
DUMP_TRAILING_COMMA
public
mixed
DUMP_TRAILING_COMMA
= 8
Properties
$defaultColors
public
static mixed
$defaultColors
$defaultOutput
public
static mixed
$defaultOutput
= 'php://stdout'
$collapseNextHash
protected
mixed
$collapseNextHash
= false
$colors
protected
mixed
$colors
$controlCharsMap
protected
static mixed
$controlCharsMap
= ["\t" => '\\t', "\n" => '\\n', "\v" => '\\v', "\f" => '\\f', "\r" => '\\r', "\x1b" => '\\e']
$controlCharsRx
protected
static mixed
$controlCharsRx
= '/[\\x00-\\x1F\\x7F]+/'
$decimalPoint
protected
mixed
$decimalPoint
= '.'
$expandNextHash
protected
mixed
$expandNextHash
= false
$flags
protected
mixed
$flags
$indentPad
protected
mixed
$indentPad
= ' '
$line
protected
mixed
$line
= ''
$lineDumper
protected
mixed
$lineDumper
$maxStringWidth
protected
mixed
$maxStringWidth
= 0
$outputStream
protected
mixed
$outputStream
$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',
]
$charset
private
string
$charset
= ''
$displayOptions
private
array<string|int, mixed>
$displayOptions
= ['fileLinkFormat' => null]
$handlesHrefGracefully
private
bool
$handlesHrefGracefully
Methods
__construct()
public
__construct([mixed $output = null ][, string $charset = null ][, int $flags = 0 ]) : mixed
Parameters
- $output : mixed = null
-
A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
- $charset : string = null
-
The default character encoding to use for non-UTF8 strings
- $flags : int = 0
-
A bit field of static::DUMP_* constants to fine tune dumps representation
dump()
Dumps a Data object.
public
dump(Data $data[, callable|resource|string|true|null $output = null ]) : string|null
Parameters
- $data : Data
- $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, string $type, string|int|float|bool|null $value) : mixed
Parameters
- $cursor : Cursor
- $type : string
- $value : string|int|float|bool|null
dumpString()
{@inheritdoc}
public
dumpString(Cursor $cursor, string $str, bool $bin, int $cut) : mixed
Parameters
- $cursor : Cursor
- $str : string
- $bin : bool
- $cut : int
enterHash()
{@inheritdoc}
public
enterHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild) : mixed
Parameters
- $cursor : Cursor
- $type : int
- $class : string|int|null
- $hasChild : bool
leaveHash()
{@inheritdoc}
public
leaveHash(Cursor $cursor, int $type, string|int|null $class, bool $hasChild, int $cut) : mixed
Parameters
- $cursor : Cursor
- $type : int
- $class : string|int|null
- $hasChild : bool
- $cut : int
setCharset()
Sets the default character encoding to use for non-UTF8 strings.
public
setCharset(string $charset) : string
Parameters
- $charset : string
Return values
string —The previous charset
setColors()
Enables/disables colored output.
public
setColors(bool $colors) : mixed
Parameters
- $colors : bool
setDisplayOptions()
Configures display options.
public
setDisplayOptions(array<string|int, mixed> $displayOptions) : mixed
Parameters
- $displayOptions : array<string|int, mixed>
-
A map of display options to customize the behavior
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
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
dumpEllipsis()
Dumps an ellipsis for cut children.
protected
dumpEllipsis(Cursor $cursor, bool $hasChild, int $cut) : mixed
Parameters
- $cursor : Cursor
- $hasChild : bool
-
When the dump of the hash has child item
- $cut : int
-
The number of items the hash has been cut by
dumpKey()
Dumps a key in a hash structure.
protected
dumpKey(Cursor $cursor) : mixed
Parameters
- $cursor : Cursor
dumpLine()
Dumps the current line.
protected
dumpLine(int $depth[, bool $endOfValue = false ]) : mixed
Parameters
- $depth : int
-
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 : bool = false
echoLine()
Generic line dumper callback.
protected
echoLine(string $line, int $depth, string $indentPad) : mixed
Parameters
- $line : string
- $depth : int
- $indentPad : string
endValue()
protected
endValue(Cursor $cursor) : mixed
Parameters
- $cursor : Cursor
style()
Decorates a value with some style.
protected
style(string $style, string $value[, array<string|int, mixed> $attr = [] ]) : string
Parameters
- $style : string
-
The type of style being applied
- $value : string
-
The value being styled
- $attr : array<string|int, mixed> = []
-
Optional context information
Return values
stringsupportsColors()
protected
supportsColors() : bool
Return values
boolutf8Encode()
Converts a non-UTF-8 string to UTF-8.
protected
utf8Encode(string|null $s) : string|null
Parameters
- $s : string|null
Return values
string|nullgetSourceLink()
private
getSourceLink(string $file, int $line) : mixed
Parameters
- $file : string
- $line : int
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
Return values
boolisWindowsTrueColor()
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.