FileAccess Orion

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
$themes  : mixed
$charset  : mixed
$displayOptions  : mixed
$extraDisplayOptions  : mixed
$handlesHrefGracefully  : 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.
setTheme()  : mixed
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" => '\\t', "\n" => '\\n', "\v" => '\\v', "\f" => '\\f', "\r" => '\\r', "\x1b" => '\\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

$themes

protected static mixed $themes = ['dark' => ['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', 'ns' => 'user-select:none;'], 'light' => ['default' => 'background:none; color:#CC7832; 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:#629755;', 'note' => 'color:#6897BB', 'ref' => 'color:#6E6E6E', 'public' => 'color:#262626', 'protected' => 'color:#262626', 'private' => 'color:#262626', 'meta' => 'color:#B729D9', 'key' => 'color:#789339', 'index' => 'color:#1299DA', 'ellipsis' => 'color:#CC7832', 'ns' => 'user-select:none;']]

$displayOptions

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

$extraDisplayOptions

private mixed $extraDisplayOptions = []

$handlesHrefGracefully

private mixed $handlesHrefGracefully

Methods

__construct()

public __construct([mixed $output = null ][, string $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

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()

{@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, 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 —

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 —

setTheme()

public setTheme(string $themeName) : mixed
Parameters
$themeName : string
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 —

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
Return values
string|null —

The string converted to UTF-8

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.

Return values
bool —

Search results