Documentation

HtmlDumper extends CliDumper
in package

HtmlDumper dumps variables as HTML.

Tags
author

Nicolas Grekas p@tchwork.com

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
$dumpHeader  : mixed
$dumpId  : mixed
$dumpPrefix  : mixed
$dumpSuffix  : mixed
$expandNextHash  : mixed
$flags  : mixed
$headerIsDumped  : mixed
$indentPad  : mixed
$lastDepth  : mixed
$line  : mixed
$lineDumper  : mixed
$maxStringWidth  : mixed
$outputStream  : mixed
$styles  : mixed
$charset  : mixed
$displayOptions  : mixed
$extraDisplayOptions  : mixed
__construct()  : mixed
dump()  : mixed
{@inheritdoc}
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.
setDumpBoundaries()  : mixed
Sets an HTML prefix and suffix that will encapse every single dump.
setDumpHeader()  : mixed
Sets an HTML header that will be dumped once in the output stream.
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
getDumpHeader()  : mixed
Dumps the HTML header.
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

Properties

$defaultColors

public static mixed $defaultColors

$defaultOutput

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

$collapseNextHash

protected mixed $collapseNextHash = false

$controlCharsMap

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

$controlCharsRx

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

$dumpPrefix

protected mixed $dumpPrefix = '<pre class=sf-dump id=%s data-indent-pad="%s">'

$dumpSuffix

protected mixed $dumpSuffix = '</pre><script>Sfdump(%s)</script>'

$expandNextHash

protected mixed $expandNextHash = false

$headerIsDumped

protected mixed $headerIsDumped = false

$maxStringWidth

protected mixed $maxStringWidth = 0

$styles

protected mixed $styles = ['default' => 'background-color:#18171B; color:#FF8400; line-height:1.2em; font:12px Menlo, Monaco, Consolas, monospace; word-wrap: break-word; white-space: pre-wrap; position:relative; z-index:99999; word-break: break-all', 'num' => 'font-weight:bold; color:#1299DA', 'const' => 'font-weight:bold', 'str' => 'font-weight:bold; color:#56DB3A', 'note' => 'color:#1299DA', 'ref' => 'color:#A0A0A0', 'public' => 'color:#FFFFFF', 'protected' => 'color:#FFFFFF', 'private' => 'color:#FFFFFF', 'meta' => 'color:#B729D9', 'key' => 'color:#56DB3A', 'index' => 'color:#1299DA', 'ellipsis' => 'color:#FF8400']

$displayOptions

private mixed $displayOptions = ['maxDepth' => 1, 'maxStringLength' => 160, 'fileLinkFormat' => null]

$extraDisplayOptions

private mixed $extraDisplayOptions = []

Methods

__construct()

public __construct([mixed $output = null ][, mixed $charset = null ], mixed $flags) : mixed
Parameters
$output : mixed = null

A line dumper callable, an opened stream or an output path, defaults to static::$defaultOutput

$charset : mixed = null

The default character encoding to use for non-UTF8 strings

$flags : mixed

A bit field of static::DUMP_* constants to fine tune dumps representation

Return values
mixed —

dump()

{@inheritdoc}

public dump(Data $data[, mixed $output = null ][, array<string|int, mixed> $extraDisplayOptions = [] ]) : mixed
Parameters
$data : Data
$output : mixed = null
$extraDisplayOptions : array<string|int, mixed> = []
Return values
mixed —

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 —

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 —

setDumpBoundaries()

Sets an HTML prefix and suffix that will encapse every single dump.

public setDumpBoundaries(string $prefix, string $suffix) : mixed
Parameters
$prefix : string

The prepended HTML string

$suffix : string

The appended HTML string

Return values
mixed —

setDumpHeader()

Sets an HTML header that will be dumped once in the output stream.

public setDumpHeader(string $header) : mixed
Parameters
$header : string

An HTML string

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 —

getDumpHeader()

Dumps the HTML header.

protected getDumpHeader() : mixed
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

private getSourceLink(mixed $file, mixed $line) : mixed
Parameters
$file : mixed
$line : mixed
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.

Return values
bool —

Search results