Dump
extends Base
in package
Parses a var_dump() and renders a syntax highlighted version of var_export().
Usage: dump($var); or in a VirtualFolder: return new Dump($var);
(Compatible with the View interface from MVC)
Disable xdebug's var_dump() for full-length, full-depth dump() output. By adding "xdebug.overload_var_dump = Off" to the php.ini
Table of Contents
- $colors : array<string|int, mixed>
- Colors based on Tomorrow Night.
- $offset : int
- The position of the cursor while parsing the var_dump() string.
- $trace : array<string|int, mixed>|null
- The trace from where the `new Dump()` originated.
- $vardump : string
- Output of the var_dump().
- $variable : mixed
- The variable to display.
- $xdebug : bool
- Detected xdebug 2.2.0 var_dump() output.
- __call() : mixed
- Report that the $method doesn't exist.
- __callStatic() : mixed
- Report that the $method doesn't exist.
- __construct() : mixed
- Constructor.
- __get() : mixed
- Report that $property doesn't exist.
- __set() : mixed
- Report that $property doesn't exist and set the property to the given $value.
- __toString() : string
- The object is used as an string.
- render() : mixed
- Renders information about the variable, like var_dump() but with improved syntax and coloring.
- assertIndentation() : mixed
- Check if the leading spaces in current line matches the indent level.
- debug() : mixed
- A mini dump for debugging this Dump parser.
- escape() : string
- Escape html output.
- parseArrayContents() : mixed
- Parse the contents of an array.
- parseAttribute() : mixed
- Parse an attribute name from an object.
- parseObjectContents() : mixed
- Parse the contents of an object.
- parseVardump() : mixed
- Parse the output from the vardump and render the html version.
- part() : string
- Return a substring of the given length of the vardump.
- position() : int|false
- Returns the relative position of the searchString inside the vardump.
- renderIndent() : mixed
- Render indent (spaces).
- renderTrace() : mixed
- Resolves the variablename and renders the "dump($x) in filename.php on line X" line.
- renderType() : mixed
- Render the content in the color of the type.
Properties
$colors
Colors based on Tomorrow Night.
private
static array<string|int, mixed>
$colors
= [
'background' => '#1d1f21',
'foreground' => '#c5c8c6',
// lightgray: [, {, ( and ,
'current' => '#282a2e',
// darkgray
'class' => '#f0c674',
// Yellow
'attribute' => '#cc6666',
// Red
'variable' => '#cc6666',
// Red: $x, $this
'method' => '#81a2be',
// Blue
'keyword' => '#b294bb',
// Purple
'resource' => '#b294bb',
// Purple
'string' => '#b5bd68',
// Green: "hello"
'number' => '#de935f',
// Orange: 0
'symbol' => '#de935f',
// Orange: true, null
'comment' => '#969896',
// Gray
'operator' => '#8abeb7',
]
Tags
$offset
The position of the cursor while parsing the var_dump() string.
private
int
$offset
$trace
The trace from where the `new Dump()` originated.
private
array<string|int, mixed>|null
$trace
$vardump
Output of the var_dump().
private
string
$vardump
$variable
The variable to display.
private
mixed
$variable
$xdebug
Detected xdebug 2.2.0 var_dump() output.
private
static bool
$xdebug
Methods
__call()
Report that the $method doesn't exist.
public
__call(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__callStatic()
Report that the $method doesn't exist.
public
static __callStatic(string $method, array<string|int, mixed> $arguments) : mixed
Parameters
- $method : string
- $arguments : array<string|int, mixed>
Return values
mixed —__construct()
Constructor.
public
__construct(mixed $variable[, mixed $backtrace = null ]) : mixed
Parameters
- $variable : mixed
-
The variable to display on render()
- $backtrace : mixed = null
Return values
mixed —__get()
Report that $property doesn't exist.
public
__get(string $property) : mixed
Parameters
- $property : string
Return values
mixed —__set()
Report that $property doesn't exist and set the property to the given $value.
public
__set(string $property, mixed $value) : mixed
Parameters
- $property : string
- $value : mixed
Return values
mixed —__toString()
The object is used as an string.
public
__toString() : string
Return values
string —render()
Renders information about the variable, like var_dump() but with improved syntax and coloring.
public
render() : mixed
Return values
mixed —assertIndentation()
Check if the leading spaces in current line matches the indent level.
private
assertIndentation(int $level) : mixed
Parameters
- $level : int
Return values
mixed —debug()
A mini dump for debugging this Dump parser.
private
debug(mixed $variable) : mixed
Parameters
- $variable : mixed
Return values
mixed —escape()
Escape html output.
private
escape(string $text) : string
Parameters
- $text : string
Return values
string —parseArrayContents()
Parse the contents of an array.
private
parseArrayContents(int $length, int $indentationLevel) : mixed
Parameters
- $length : int
-
The number of items in this array.
- $indentationLevel : int
-
The number of spaces the elements are indented.
Return values
mixed —parseAttribute()
Parse an attribute name from an object.
private
parseAttribute(string $attribute) : mixed
Parameters
- $attribute : string
-
Examples: '"log"', '"error_types:private"' or '"error_types":"ErrorHandler":private'
Return values
mixed —parseObjectContents()
Parse the contents of an object.
private
parseObjectContents(int $length, int $indentationLevel) : mixed
Parameters
- $length : int
-
The number of attribute in this object.
- $indentationLevel : int
-
The number of spaces the elements are indented.
Return values
mixed —parseVardump()
Parse the output from the vardump and render the html version.
private
parseVardump(int $indentationLevel) : mixed
Parameters
- $indentationLevel : int
-
The level of indentation (for arrays & objects)
Return values
mixed —part()
Return a substring of the given length of the vardump.
private
part(int $length, int $offset) : string
Parameters
- $length : int
-
Length of the substring
- $offset : int
-
Relative offset
Return values
string —position()
Returns the relative position of the searchString inside the vardump.
private
position(string $searchString, int $offset) : int|false
Parameters
- $searchString : string
-
The
- $offset : int
-
Relative offset
Return values
int|false —renderIndent()
Render indent (spaces).
private
renderIndent(int $level) : mixed
Parameters
- $level : int
Return values
mixed —renderTrace()
Resolves the variablename and renders the "dump($x) in filename.php on line X" line.
private
renderTrace() : mixed
Return values
mixed —renderType()
Render the content in the color of the type.
private
renderType(string $type, string $content) : mixed
Parameters
- $type : string
-
ENUM: 'class', 'attribute', 'variable', 'method', 'keyword', 'resource', 'string', 'number', 'symbol', 'comment' or 'operator'
- $content : string