pclib  2.3.2
Lightweight PHP framework
Public Member Functions | Data Fields | Protected Member Functions
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...
 
 addEvent ($name, $callback)
 Add event handler to $object->$name property. More...
 
 toArray ()
 Convert object to array. More...
 

Data Fields

 $useHtml = true
 Html or plaintext output. More...
 
 $maxLevel = 4
 Maximum level of vardump. More...
 
 $colors = array('string' => 'red', 'number' => 'blue', 'keyword' => 'brown', 'other' => 'green')
 Colors for html output. More...
 
- Data Fields inherited from BaseObject
 $onNewInstance
 Occurs when new instance of the class is created. More...
 
 $onMissingMethod
 Occurs when called method does not exist. More...
 
 $serviceLocator
 var function() Return service object when requested with service(). More...
 

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
 fireEvent ($name, array $args=array())
 Run all event handlers in $object->$name property. More...
 
 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 ()
 Set or retireve default parameters of the object. More...
 

Detailed Description

Provides API for variable dumps, stack trace and profiling.

Member Function Documentation

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

Return metadata of the $variable.

It is called recursively for nested variables.

See also
getdump()
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 (   $variable,
  $level 
)
protected

Return metadata of the array $variable.

See also
dumparray()
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; $variables (array of variables)

Returns
string $html
getObject (   $variable,
  $level 
)
protected

Return metadata of the object $variable.

See also
dumparray()
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 (   $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 (   $var)

Do default php var_dump().

Helper for strargs().

Returns
string variable dump
strArgs (   $args)
protected

Return function arguments as string.

See also
gettrace()
strDump ( array  $meta,
array  $options = array() 
)
protected

Convert metadata to html/text output recursively.

See also
getdump()
strSimpleArray ( array  $nodes = null)
protected

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

See also
getdump()
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 (   $e = null)
protected

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

See also
gettrace()
Returns
array $strace
tracePath (   $levels = 100,
  $e = null 
)

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

Helper for errordump.

Field Documentation

$colors = array('string' => 'red', 'number' => 'blue', 'keyword' => 'brown', 'other' => 'green')

Colors for html output.

$maxLevel = 4

Maximum level of vardump.

See also
getdump()
$useHtml = true

Html or plaintext output.


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