CliDumper
extends AbstractDumper
in package
CliDumper dumps variables for command line output.
Tags
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
- $outputStream : mixed
- $styles : mixed
- $charset : mixed
- $displayOptions : mixed
- $handlesHrefGracefully : 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.
- 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', "
" => '\n', "" => '\v', "" => '\f', "
" => '\r', "" => '\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
mixed
$charset
= ''
$displayOptions
private
mixed
$displayOptions
= ['fileLinkFormat' => null]
$handlesHrefGracefully
private
mixed
$handlesHrefGracefully
Methods
__construct()
public
__construct([mixed $output = null ][, string|null $charset = null ], int $flags) : mixed
Parameters
- $output : mixed = null
-
A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput
- $charset : string|null = null
-
The default character encoding to use for non-UTF8 strings
- $flags : int
-
A bit field of static::DUMP_* constants to fine tune dumps representation
Return values
mixed —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, mixed $value) : mixed
Parameters
- $cursor : Cursor
- $type : string
- $value : mixed
Return values
mixed —dumpString()
{@inheritdoc}
public
dumpString(Cursor $cursor, string $str, bool $bin, int $cut) : mixed
Parameters
- $cursor : Cursor
- $str : string
- $bin : bool
- $cut : int
Return values
mixed —enterHash()
{@inheritdoc}
public
enterHash(Cursor $cursor, int $type, mixed $class, bool $hasChild) : mixed
Parameters
- $cursor : Cursor
- $type : int
- $class : mixed
- $hasChild : bool
Return values
mixed —leaveHash()
{@inheritdoc}
public
leaveHash(Cursor $cursor, int $type, mixed $class, bool $hasChild, int $cut) : mixed
Parameters
- $cursor : Cursor
- $type : int
- $class : mixed
- $hasChild : bool
- $cut : int
Return values
mixed —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
Return values
mixed —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
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
- $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
Return values
mixed —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
Return values
mixed —echoLine()
Generic line dumper callback.
protected
echoLine(string $line, int $depth, string $indentPad) : mixed
Parameters
- $line : string
- $depth : int
- $indentPad : string
Return values
mixed —endValue()
protected
endValue(Cursor $cursor) : mixed
Parameters
- $cursor : Cursor
Return values
mixed —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
string —supportsColors()
protected
supportsColors() : bool
Return values
bool —utf8Encode()
Converts a non-UTF-8 string to UTF-8.
protected
utf8Encode(string|null $s) : string|null
Parameters
- $s : string|null
Return values
string|null —getSourceLink()
private
getSourceLink(string $file, int $line) : mixed
Parameters
- $file : string
- $line : int
Return values
mixed —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.