pclib  3.3.0
Lightweight PHP framework
Debugger Class Reference

Provides API for variable dumps, stack trace and profiling. More...

Inheritance diagram for Debugger:
BaseObject

Public Member Functions

 getDump (array $variables, array $options=array())
 Return variable dump as html/plaintext. More...
 
 getSource ($fileName, $line, $width=3)
 Return part of source code at line $line in file $filename. More...
 
 getTrace ($e=null)
 Return stack-trace of an exception or place where it is called. More...
 
 tracePath ($levels=100, $e=null)
 Return stack trace file:line information - ex: index.php:10 -> db.php:220. More...
 
 errorDump ($message, $e=null)
 Print error message $message with stack trace and optionally part of source code where error occured. More...
 
 simpleDump ($var)
 Do default php var_dump(). More...
 
 timeLog ($name, $in)
 Log current time in ms with label $name. More...
 
 getTimeLog ()
 Return profile table, collected by timelog() calls.
 
- Public Member Functions inherited from BaseObject
 loadDefaults ($className=null)
 Load default parameters of class $className into object instance.
 
 setProperties (array $defaults)
 Set public properties of object from the array. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $useHtml = true
 Html or plaintext output.
 
 $maxLevel = 4
 Maximum level of vardump. More...
 
 $colors = array('string' => 'red', 'number' => 'blue', 'keyword' => 'brown', 'other' => 'green')
 Colors for html output.
 
- Data Fields inherited from BaseObject
 $serviceLocator
 var function() Return service object when requested with service().
 

Protected Member Functions

 dumpArray ($name, $variable, $level=0)
 Return metadata of the $variable. More...
 
 getArray ($variable, $level)
 Return metadata of the array $variable. More...
 
 getObject ($variable, $level)
 Return metadata of the object $variable. More...
 
 strSimpleArray (?array $nodes=null)
 Return simple dump of indexed array $nodes – [one,two,three,...]. More...
 
 spanBox ($id, $title, $content, $opened=true, $css_title='cursor:pointer')
 Make clickable/expandable group around $content.
 
 strDump (array $meta, array $options=array())
 Convert metadata to html/text output recursively. More...
 
 stringify ($v, $colorize=true)
 Return string representation of variable $v.
 
 traceArray ($e=null)
 Return stack-trace array of an exception or place where it is called. More...
 
 strArgs ($args)
 Return function arguments as string. More...
 
- Protected Member Functions inherited from BaseObject
 service ($service, $default=null)
 Try acquire $service and load it into property $this->$service. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseObject
static defaults (... $args)
 Set or retireve default parameters of the object. More...
 

Detailed Description

Provides API for variable dumps, stack trace and profiling.

Member Function Documentation

◆ dumpArray()

dumpArray (   $name,
  $variable,
  $level = 0 
)
protected

Return metadata of the $variable.

It is called recursively for nested variables.

See also
getdump()

◆ errorDump()

errorDump (   $message,
  $e = null 
)

Print error message $message with stack trace and optionally part of source code where error occured.

Used in pclib error handlers and for function dump().

◆ getArray()

getArray (   $variable,
  $level 
)
protected

Return metadata of the array $variable.

See also
dumparray()

◆ getDump()

getDump ( array  $variables,
array  $options = array() 
)

Return variable dump as html/plaintext.

It is advanced version of var_dump(). Typically you will use pclib shortcut function dump(), which is wrapper of this method. Switch text/html output with $app->debugger->usehtml = true/false; @params $variables (array of variables)

Returns
string $html

◆ getObject()

getObject (   $variable,
  $level 
)
protected

Return metadata of the object $variable.

See also
dumparray()

◆ getSource()

getSource (   $fileName,
  $line,
  $width = 3 
)

Return part of source code at line $line in file $filename.

You can enable showing source code in debugger messages by setting $app->debugger->showsource = true;

◆ getTrace()

getTrace (   $e = null)

Return stack-trace of an exception or place where it is called.

Switch text/html output with $app->debugger->usehtml = true/false;

Returns
string $html

◆ simpleDump()

simpleDump (   $var)

Do default php var_dump().

Helper for strargs().

Returns
string variable dump

◆ strArgs()

strArgs (   $args)
protected

Return function arguments as string.

See also
gettrace()

◆ strDump()

strDump ( array  $meta,
array  $options = array() 
)
protected

Convert metadata to html/text output recursively.

See also
getdump()

◆ strSimpleArray()

strSimpleArray ( ?array  $nodes = null)
protected

Return simple dump of indexed array $nodes – [one,two,three,...].

See also
getdump()

◆ timeLog()

timeLog (   $name,
  $in 
)

Log current time in ms with label $name.

Useful for profiling. Parameter $in = 1/0 indicates beginning or end of time interval.

See also
gettimelog()

◆ traceArray()

traceArray (   $e = null)
protected

Return stack-trace array of an exception or place where it is called.

See also
gettrace()
Returns
array $strace

◆ tracePath()

tracePath (   $levels = 100,
  $e = null 
)

Return stack trace file:line information - ex: index.php:10 -> db.php:220.

Helper for errordump.

Field Documentation

◆ $maxLevel

$maxLevel = 4

Maximum level of vardump.

See also
getdump()

The documentation for this class was generated from the following file: