DebuggerUtility
This class is a backport of the corresponding class of TYPO3 Flow.
All credits go to the TYPO3 Flow team.
A debugging utility class
Table of Contents
Constants
- PLAINTEXT_INDENT = ' '
Properties
- $blacklistedClassNames : array<string|int, mixed>
- Hardcoded list of Extbase class names (regex) which should not be displayed during debugging
- $blacklistedPropertyNames : array<string|int, mixed>
- Hardcoded list of property names (regex) which should not be displayed during debugging
- $maxDepth : int
- Defines the max recursion depth of the dump, set to 8 due to common memory limits
- $renderedObjects : ObjectStorage
- $stylesheetEchoed : bool
- Is set to TRUE once the CSS file is included in the current page to prevent double inclusions of the CSS file.
Methods
- var_dump() : string
- A var_dump function optimized for Extbase's object structures
- ansiEscapeWrap() : callable
- Wrap a string with the ANSI escape sequence for colorful output
- clearState() : void
- Clear the state of the debugger
- cssTreeToString() : string
- Converts a CSS tree to a CSS stylesheet string
- escapeConsoleText() : string
- escapeHtml() : string
- html() : callable
- isAlreadyRendered() : bool
- Checks if a given object was already rendered.
- isBlacklisted() : bool
- Checks if a given object or property should be excluded/filtered
- render() : string
- renderArray() : array<string|int, mixed>|callable
- Renders a dump of the given array
- renderClosure() : array<string|int, mixed>|callable
- Renders a dump of the given closure
- renderCollection() : array<string|int, mixed>
- renderContent() : string|array<string|int, mixed>
- renderDump() : array<string|int, mixed>|callable|string
- Renders a dump of the given value
- renderHeader() : array<string|int, string|callable>
- Renders the header of a given object/collection. It is usually the class name along with some flags.
- renderObject() : array<string|int, mixed>|callable
- Renders a dump of the given object
- resolveNonceValue() : string
- styled() : callable|string
Constants
PLAINTEXT_INDENT
public
mixed
PLAINTEXT_INDENT
= ' '
Properties
$blacklistedClassNames
Hardcoded list of Extbase class names (regex) which should not be displayed during debugging
protected
static array<string|int, mixed>
$blacklistedClassNames
= [\TYPO3\CMS\Extbase\Reflection\ReflectionService::class, \TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMapper::class, \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager::class, \TYPO3\CMS\Extbase\Persistence\Generic\Qom\QueryObjectModelFactory::class, \TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer::class]
$blacklistedPropertyNames
Hardcoded list of property names (regex) which should not be displayed during debugging
protected
static array<string|int, mixed>
$blacklistedPropertyNames
= ['warning']
$maxDepth
Defines the max recursion depth of the dump, set to 8 due to common memory limits
protected
static int
$maxDepth
= 8
$renderedObjects
protected
static ObjectStorage
$renderedObjects
$stylesheetEchoed
Is set to TRUE once the CSS file is included in the current page to prevent double inclusions of the CSS file.
protected
static bool
$stylesheetEchoed
= false
Methods
var_dump()
A var_dump function optimized for Extbase's object structures
public
static var_dump(mixed $variable[, string $title = null ][, int $maxDepth = 8 ][, bool $plainText = false ][, bool $ansiColors = true ][, bool $return = false ][, array<string|int, mixed> $blacklistedClassNames = null ][, array<string|int, mixed> $blacklistedPropertyNames = null ]) : string
Parameters
- $variable : mixed
-
The value to dump
- $title : string = null
-
optional custom title for the debug output
- $maxDepth : int = 8
-
Sets the max recursion depth of the dump. De- or increase the number according to your needs and memory limit.
- $plainText : bool = false
-
If TRUE, the dump is in plain text, if FALSE the debug output is in HTML format.
- $ansiColors : bool = true
-
If TRUE (default), ANSI color codes is added to the output, if FALSE the debug output not colored.
- $return : bool = false
-
if TRUE, the dump is returned for custom post-processing (e.g. embed in custom HTML). If FALSE (default), the dump is directly displayed.
- $blacklistedClassNames : array<string|int, mixed> = null
-
An array of class names (RegEx) to be filtered. Default is an array of some common class names.
- $blacklistedPropertyNames : array<string|int, mixed> = null
-
An array of property names and/or array keys (RegEx) to be filtered. Default is an array of some common property names.
Return values
string —if $return is TRUE, the dump is returned. By default, the dump is directly displayed, and nothing is returned.
ansiEscapeWrap()
Wrap a string with the ANSI escape sequence for colorful output
protected
static ansiEscapeWrap(string $string, string $ansiColorSequence, bool $plainText, bool $ansiColors) : callable
Parameters
- $string : string
-
The string to wrap
- $ansiColorSequence : string
-
The ansi color sequence (e.g. "1;37")
- $plainText : bool
-
If FALSE, the string will be HTML encoded
- $ansiColors : bool
-
If TRUE, the string will have console colors applied
Return values
callable —The wrapped or raw string
clearState()
Clear the state of the debugger
protected
static clearState() : void
cssTreeToString()
Converts a CSS tree to a CSS stylesheet string
protected
static cssTreeToString(array<string, array<string, string>> $cssTree) : string
Example input:
[
'.my-class' => [
'display' => 'block',
'color' => 'black',
],
'.other-class' => [
'display' => 'flex',
],
]
Output: .my-class{display:block;color:black} .other-class{display:flex}
Parameters
- $cssTree : array<string, array<string, string>>
Return values
stringescapeConsoleText()
protected
static escapeConsoleText(string $text) : string
Parameters
- $text : string
Return values
stringescapeHtml()
protected
static escapeHtml(string $text) : string
Parameters
- $text : string
Return values
stringhtml()
protected
static html(string $tagName, array<string|int, mixed> $attributes[, string|array<string|int, mixed>|callable|null $content = null ]) : callable
Parameters
- $tagName : string
- $attributes : array<string|int, mixed>
- $content : string|array<string|int, mixed>|callable|null = null
Return values
callableisAlreadyRendered()
Checks if a given object was already rendered.
protected
static isAlreadyRendered(object $object) : bool
Parameters
- $object : object
Return values
bool —TRUE if the given object was already rendered
isBlacklisted()
Checks if a given object or property should be excluded/filtered
protected
static isBlacklisted(object $value) : bool
Parameters
- $value : object
-
A ReflectionProperty or other Object
Return values
bool —TRUE if the given object should be filtered
render()
protected
static render(string|callable|array<string|int, mixed> $content, callable $escape) : string
Parameters
- $content : string|callable|array<string|int, mixed>
- $escape : callable
Return values
stringrenderArray()
Renders a dump of the given array
protected
static renderArray(array<string|int, mixed> $array, int $level[, bool $plainText = false ][, bool $ansiColors = false ][, array<string|int, mixed> $headerPrefix = [] ]) : array<string|int, mixed>|callable
Parameters
- $array : array<string|int, mixed>
- $level : int
- $plainText : bool = false
- $ansiColors : bool = false
- $headerPrefix : array<string|int, mixed> = []
Return values
array<string|int, mixed>|callablerenderClosure()
Renders a dump of the given closure
protected
static renderClosure(Closure $object, int $level[, bool $plainText = false ][, bool $ansiColors = false ][, array<string|int, mixed> $headerPrefix = [] ]) : array<string|int, mixed>|callable
Parameters
- $object : Closure
- $level : int
- $plainText : bool = false
- $ansiColors : bool = false
- $headerPrefix : array<string|int, mixed> = []
Return values
array<string|int, mixed>|callablerenderCollection()
protected
static renderCollection(iterable<string|int, mixed> $collection, int $level, bool $plainText, bool $ansiColors) : array<string|int, mixed>
Parameters
- $collection : iterable<string|int, mixed>
- $level : int
- $plainText : bool
- $ansiColors : bool
Return values
array<string|int, mixed>renderContent()
protected
static renderContent(object $object, int $level, bool $plainText, bool $ansiColors) : string|array<string|int, mixed>
Parameters
- $object : object
- $level : int
- $plainText : bool
- $ansiColors : bool
Return values
string|array<string|int, mixed>renderDump()
Renders a dump of the given value
protected
static renderDump(mixed $value, int $level, bool $plainText, bool $ansiColors[, array<string|int, mixed> $headerPrefix = [] ]) : array<string|int, mixed>|callable|string
Parameters
- $value : mixed
- $level : int
- $plainText : bool
- $ansiColors : bool
- $headerPrefix : array<string|int, mixed> = []
Return values
array<string|int, mixed>|callable|stringrenderHeader()
Renders the header of a given object/collection. It is usually the class name along with some flags.
protected
static renderHeader(object $object, int $level, bool $plainText, bool $ansiColors, array<string|int, mixed> $headerPrefix) : array<string|int, string|callable>
Parameters
- $object : object
- $level : int
- $plainText : bool
- $ansiColors : bool
- $headerPrefix : array<string|int, mixed>
Return values
array<string|int, string|callable> —string The rendered header with tags
renderObject()
Renders a dump of the given object
protected
static renderObject(object $object, int $level[, bool $plainText = false ][, bool $ansiColors = false ][, array<string|int, mixed> $headerPrefix = [] ]) : array<string|int, mixed>|callable
Parameters
- $object : object
- $level : int
- $plainText : bool = false
- $ansiColors : bool = false
- $headerPrefix : array<string|int, mixed> = []
Return values
array<string|int, mixed>|callableresolveNonceValue()
protected
static resolveNonceValue() : string
Return values
stringstyled()
protected
static styled(string $content, string $style, bool $plainText, bool $ansiColors[, int $spaceBefore = 0 ][, int $spaceAfter = 0 ]) : callable|string
Parameters
- $content : string
- $style : string
- $plainText : bool
- $ansiColors : bool
- $spaceBefore : int = 0
- $spaceAfter : int = 0