Inspect

Methods for inspecting/debugging variables and viewing errors and exceptions.
Source
Inspect.php
Implements
IInspect
Depends on
Arta , Binder , ErrorException

Static Methods

dump

string Inspect::dump(array vars, bool browseObjects, bool print=true)

Dump variable(s) as string. HTML or text output depends on "Arta::$HtmlDebug" Use the shortcut global functions "I(var1, var2, ...);" and "inspect(var1, var2, ...);" to dump variables instead of this method. When debugging an object "inspect()" displays all properties and methods but "I()" does not expand the object however "I()" displays sophisticated info about instances of "IModel", "IRequest", "IResponse", "IDbAbstract" and "ErrorException".

Arguments

    vars (array)
    Array of variables to be dumped
    browseObjects (bool)
    true=expand objects
    print=true (bool)
    true=print the dump and die, false=return the dump

Returns

string
Dump As HTML or text

dumpDB

string Inspect::dumpDB(array vars, bool print=true)

Inspect database message renderer. This method is used internally by instances or "IDBabstract" "inspect()" method to render messages. HTML or text output depends on "Arta::$HtmlDebug".

Arguments

    vars (array)
    ['Last query': [SQL, params], 'SQL queries': [queus,], 'Active queue': (string), 'Last commit': (string)]
    print=true (bool)
    true=print the dump and die, false=return the dump

Returns

string
HTML dump

dumpException

string Inspect::dumpException(ErrorException err, string title, bool die=true, bool print=true)

Dump/render exceptions. HTML or text output depends on "Arta::$HtmlDebug".

Arguments

    err (ErrorException)
    Object to be dumped
    title (string)
    Title of the error message
    die=true (bool)
    true=exit after printing message
    print=true (bool)
    Print the dump or return it

Returns

string
Dump of exception

dumpHtml

string Inspect::dumpHtml(array vars, bool browseObjects, bool print=true)

Dump variable(s) as HTML.

Arguments

    vars (array)
    Array of variables to be dumped
    browseObjects (bool)
    true=expand objects
    print=true (bool)
    true=print the dump and die, false=return the dump

Returns

string
HTML dump

dumpText

string Inspect::dumpText(array vars, bool browseObjects, bool print=true)

Dump variable(s) as unformatted text.

Arguments

    vars (array)
    Array of variables to be dumped
    browseObjects (bool)
    true=expand objects
    print=true (bool)
    true=print the dump and die, false=return the dump

Returns

string
Text dump

flattenDict

string Inspect::flattenDict(array vars)

Recursively flatten a dictionary to string. {k1: v1, k2: v1, k3 {k4: v4},} ==> '(k1: v1, k2: v1, k2: (k4: v4))'

Arguments

    vars (array)
    Array to be flattened

Returns

string
The flattened array

flattenList

string Inspect::flattenList(array vars)

Recursively flatten a list to string. [v1, v2, [v3, v4],] ==> '(v1, v2, (v3, v4))'

Arguments

    vars (array)
    Array to be flattened (keys are ignored)

Returns

string
The flattened array