PhpToolCase
Api Documentation Version 0.9.2
PtcDebug Class Reference

Static Public Member Functions

static getBuffer ()
 Returns the buffer array. More...
 
static getCoverage ()
 Retrieves the code coverage analysis data stored in the PtcDebug::$_finalCoverageData property. More...
 
static addCss ($css)
 Adds style properties to the floating panel styles array. More...
 
static checkReferer ()
 Checks if the debug "url_key" and "url_pass" are set on the referer url. More...
 
static setErrorHandler ($dieOnFatal=true)
 Sets the error handler to be the debug class. More...
 
static load ($options=null)
 Loads the debug interface and/or the console class if requested. More...
 
static tickHandler ()
 The ticks handler to execute all tickable functions. More...
 
static startCoverage ()
 Starts the code coverage analysis utility to find executed lines. More...
 
static stopCoverage ()
 Stops the code coverage analysis utility. More...
 
static startTrace ()
 Starts the function calls trace utility. More...
 
static stopTrace ()
 Stops the function calls trace utility. More...
 
static excludeFromTrace ($functions)
 Excludes functions from the function calls tracing engine. More...
 
static watch ($variableName, $callback=null)
 Watches a variable that is in a declare(ticks=n); code block, for changes. More...
 
static bufferLog ($string, $statement=null, $category=null)
 Writes data to the messages panel. More...
 
static bufferSql ($string, $statement=null, $category=null)
 Writes data to the sql panel. More...
 
static stopTimer ($reference=null, $precision=1)
 Monitors the execution of php code, or sql queries based on a reference. More...
 
static convertMemUsage ($val, $precision=2)
 Convert memory_usage( ) into a readable format. More...
 
static errorHandler ($errno, $errstr, $errfile, $errline)
 Handles php errors. More...
 
static exceptionHandler ($exception)
 Exception handler, catches exceptions that are not in a try/catch block. More...
 
static addToBuffer ($reference, $string, $statement=null)
 Attaches a message to the end of the buffer array to add data based on a reference. More...
 
static processBuffer ()
 Processes the buffer to show the interface and/or the console messages. More...
 
static findString ($query, $path=null, $last=1)
 Searches files for a string inside a given folder recursively. More...
 
static highlightFile ($file, $line=null)
 File highlighter that opens a popup window inspect source code. More...
 
static showSearchPopup ($string, $path=null)
 Shows the search popup window with the result. More...
 

Static Protected Member Functions

static _debugConsole ()
 Sends the buffer to the PhpConsole class. More...
 
static _checkAccess ($allowedIps=null)
 Checks if a given ip has access. More...
 
static _setSessionVars ()
 Sets session vars to control which panels will be shown. More...
 
static _disablePanels ()
 Controls which panels will be shown with $_GET variable "hidepanels". More...
 
static _buildBuffer ($type, $string, $statement=null, $category=null)
 Builds the buffer. More...
 
static _watchCallback ()
 Callback function that checks if a given variable has changed. More...
 
static _codeCoverageAnalysis ($backtrace=null)
 Collect data for code coverage analysis. More...
 
static _formatVar ($var)
 Evaluates the type of variable for output. More...
 
static _findWatchVar ($variableName)
 Retrieves the variable to watch from the "$GLOBALS". More...
 
static _findReference ($reference, $type=1)
 Finds a value in the buffer based on a reference (the "$statement") More...
 
static _doDump (&$var, $varName=NULL, $indent=NULL, $reference=NULL, $depth=0)
 Custom dump to properly format a given variable and make it more friendly to read. More...
 
static _sortBuffer ()
 Sorts the buffer. More...
 
static _debugTrace ($depth=NULL)
 Trace php as best as we can. More...
 
static _lastError ()
 Gets the fatal error on shutdown. More...
 
static _buildInterface ()
 Builds the debug interface. More...
 
static _buildMenu ()
 Builds the debug menu. More...
 
static _menuLinks ($id, $title, $text)
 Builds the menu links. More...
 
static _msgType ($msg=NULL)
 Checks message types. More...
 
static _buildHtmlTable ($type)
 Builds the html log and sql tables. More...
 
static _buildTraceLink ($file, $line=null)
 Builds the link for the code highlighter popup. More...
 
static _buildTraceTree ($var, $className=null, $styleColor=null)
 Builds the tree for the links in the vars & config panel. More...
 
static _buildMsgPanel ($type, $panelId)
 Builds the log/sql panel. More...
 
static _buildTimerPanel ()
 Builds the timer panel. More...
 
static _buildAnalysisPanel ()
 Builds the Analysis panel for code coverage analysis. More...
 
static _buildCoverageData ()
 Builds the html data for the code coverage analysis. More...
 
static _buildTraceData ()
 Builds the html data for the function calls trace. More...
 
static _buildVarsPanel ()
 Builds the vars panel. More...
 
static _buildInnerVars ($panelId, $linkTitle, $array)
 Builds the inner vars div. More...
 
static _buildW3cPanel ()
 Builds the W3C panel. More...
 
static _buildPhpInfo ()
 Formats phpinfo() function. More...
 
static _includeCss ()
 Includes the css for the interface. More...
 
static _includeJs ()
 Includes the javascript for the interface. More...
 
static _compressHtml ($html)
 Compresses the html before render. More...
 
static _phpInfoArray ()
 Formats phpinfo() into an array. More...
 
static _disableOpcodeCache ()
 Attempts to disable any detetected opcode caches / optimizers. More...
 
static _traceFunctionCalls ($trace=null)
 Function calls trace engine. More...
 
static _cleanBuffer ($var)
 Removes html entities from the buffer. More...
 
static _getSessionVars ($var=null)
 Retrieves the session var for the ptcdebug class. More...
 

Static Protected Attributes

static $_defaultOptions
 Default options for the debug class. More...
 
static $_excludeMethods =array( )
 Array of methods excluded from the backtrace. More...
 
static $_coverageData = null
 Code coverage analysis storage. More...
 
static $_finalCoverageData = array( )
 Final data array for the code coveage. More...
 
static $_traceData = null
 Function calls tracing storage property. More...
 
static $_finalTraceData = array( )
 Final data array for the function calls trace. More...
 
static $_options = array( )
 Array with all options. More...
 
static $_buffer = array( )
 The debug buffer. More...
 
static $_startTime = null
 Application start time. More...
 
static $_endTime = null
 Application end time. More...
 
static $_consoleStarted = false
 Decides if we should send the buffer to the PhpConsole class. More...
 
static $_watchedVars = array()
 Array of watched variables declared. More...
 
static $_tickTime = 0
 Tick execution time property. More...
 
static $_countTime = true
 Exclude PtcDebug::$_buildBuffer from execution timing property. More...
 
static $_codeCoverage = false
 Code coverage analysis property to start coverage. More...
 
static $_functionTrace = false
 Function calls trace property to start the analysis. More...
 
static $_disableOpcode = true
 Controlls when to disable opcode cache. More...
 
static $_excludeFromTrace = array( )
 Exclude functions from the function calls trace array. More...
 
static $_panelCss
 Property that holds the css for the floating panel. More...
 

Member Function Documentation

static _buildAnalysisPanel ( )
staticprotected

Builds the Analysis panel for code coverage analysis.

Definition at line 1650 of file PtcDebug.php.

static _buildBuffer (   $type,
  $string,
  $statement = null,
  $category = null 
)
staticprotected

Builds the buffer.

Parameters
string$typelog/sql
mixed$stringthe string to pass
mixed$statementsome statement preceding the string
string$categorya category for the message

Definition at line 859 of file PtcDebug.php.

static _buildCoverageData ( )
staticprotected

Builds the html data for the code coverage analysis.

Definition at line 1679 of file PtcDebug.php.

static _buildHtmlTable (   $type)
staticprotected

Builds the html log and sql tables.

Parameters
string$typesql|log
Returns
the html table data

Definition at line 1463 of file PtcDebug.php.

static _buildInnerVars (   $panelId,
  $linkTitle,
  $array 
)
staticprotected

Builds the inner vars div.

Parameters
string$panelIdthe id of the panel to show/hide
string$linkTitlethe title of the link
string$arrayarray of parameters

Definition at line 1831 of file PtcDebug.php.

static _buildInterface ( )
staticprotected

Builds the debug interface.

Returns
the html with interface

Definition at line 1364 of file PtcDebug.php.

static _buildMenu ( )
staticprotected

Builds the debug menu.

Returns
the html menu compressed

Definition at line 1387 of file PtcDebug.php.

static _buildMsgPanel (   $type,
  $panelId 
)
staticprotected

Builds the log/sql panel.

Parameters
$typelog or sql
$panelIdome id for the panel

Definition at line 1622 of file PtcDebug.php.

static _buildPhpInfo ( )
staticprotected

Formats phpinfo() function.

Definition at line 1874 of file PtcDebug.php.

static _buildTimerPanel ( )
staticprotected

Builds the timer panel.

Definition at line 1637 of file PtcDebug.php.

static _buildTraceData ( )
staticprotected

Builds the html data for the function calls trace.

Definition at line 1712 of file PtcDebug.php.

static _buildTraceLink (   $file,
  $line = null 
)
staticprotected

Builds the link for the code highlighter popup.

Parameters
string$filethe full path to the file
string$linethe line to be highlighted

Definition at line 1574 of file PtcDebug.php.

static _buildTraceTree (   $var,
  $className = null,
  $styleColor = null 
)
staticprotected

Builds the tree for the links in the vars & config panel.

Parameters
mixed$varthe variable
string$classNamea css class
string$styleColorthe color for

Definition at line 1596 of file PtcDebug.php.

static _buildVarsPanel ( )
staticprotected

Builds the vars panel.

Definition at line 1781 of file PtcDebug.php.

static _buildW3cPanel ( )
staticprotected

Builds the W3C panel.

Definition at line 1841 of file PtcDebug.php.

static _checkAccess (   $allowedIps = null)
staticprotected

Checks if a given ip has access.

Parameters
string | array$allowedIpsthe ip's that are allowed

Definition at line 793 of file PtcDebug.php.

static _cleanBuffer (   $var)
staticprotected

Removes html entities from the buffer.

Parameters
string$varsome string

Definition at line 2179 of file PtcDebug.php.

static _codeCoverageAnalysis (   $backtrace = null)
staticprotected

Collect data for code coverage analysis.

Parameters
array$backtracethe debug_backtrace( )

Definition at line 975 of file PtcDebug.php.

static _compressHtml (   $html)
staticprotected

Compresses the html before render.

Parameters
string$htmlsome html code

Definition at line 2070 of file PtcDebug.php.

static _debugConsole ( )
staticprotected

Sends the buffer to the PhpConsole class.

See Ajax Debugging

Definition at line 726 of file PtcDebug.php.

static _debugTrace (   $depth = NULL)
staticprotected

Trace php as best as we can.

Parameters
int$depththe maximum trace depth
Returns
the trace without the methods in the PtcDebug::$_excludeMethods property

Definition at line 1307 of file PtcDebug.php.

static _disableOpcodeCache ( )
staticprotected

Attempts to disable any detetected opcode caches / optimizers.

Definition at line 2107 of file PtcDebug.php.

static _disablePanels ( )
staticprotected

Controls which panels will be shown with $_GET variable "hidepanels".

Definition at line 818 of file PtcDebug.php.

static _doDump ( $var,
  $varName = NULL,
  $indent = NULL,
  $reference = NULL,
  $depth = 0 
)
staticprotected

Custom dump to properly format a given variable and make it more friendly to read.

Parameters
mixed$varthe string to pass
mixed$varNamesome statement preceding the variable
string$indentuses "|" as indents by default
string$referencea reference to prevent recursion
int$depthmaximun depth
Returns
the html output with the variable

Definition at line 1083 of file PtcDebug.php.

static _findReference (   $reference,
  $type = 1 
)
staticprotected

Finds a value in the buffer based on a reference (the "$statement")

Parameters
string$referencethe reference to look for
numeric$type"1" to time execution, "2" to attach data to a message
Returns
the array if the given reference is found in the buffer

Definition at line 1048 of file PtcDebug.php.

static _findWatchVar (   $variableName)
staticprotected

Retrieves the variable to watch from the "$GLOBALS".

Parameters
string$variableNamethe name of the variable to find
Returns
the watched variable if found, otherwise null

Definition at line 1019 of file PtcDebug.php.

static _formatVar (   $var)
staticprotected

Evaluates the type of variable for output.

Parameters
mixed$varthe variable to pass
Returns
the html output with the variable content

Definition at line 1000 of file PtcDebug.php.

static _getSessionVars (   $var = null)
staticprotected

Retrieves the session var for the ptcdebug class.

Parameters
string$varthe session var to retrieve

Definition at line 2187 of file PtcDebug.php.

static _includeCss ( )
staticprotected

Includes the css for the interface.

Definition at line 1886 of file PtcDebug.php.

static _includeJs ( )
staticprotected

Includes the javascript for the interface.

Definition at line 1895 of file PtcDebug.php.

static _lastError ( )
staticprotected

Gets the fatal error on shutdown.

Definition at line 1347 of file PtcDebug.php.

static _menuLinks (   $id,
  $title,
  $text 
)
staticprotected

Builds the menu links.

Parameters
string$idthe panel id
string$titlethe panel title
string$textthe text for the link
Returns
the html anchor tag

Definition at line 1415 of file PtcDebug.php.

static _msgType (   $msg = NULL)
staticprotected

Checks message types.

Parameters
string | numeric$msgphp standards
Returns
the message type as a readable string

Definition at line 1428 of file PtcDebug.php.

static _phpInfoArray ( )
staticprotected

Formats phpinfo() into an array.

Definition at line 2082 of file PtcDebug.php.

static _setSessionVars ( )
staticprotected

Sets session vars to control which panels will be shown.

Definition at line 808 of file PtcDebug.php.

static _sortBuffer ( )
staticprotected

Sorts the buffer.

Returns
the sorted buffer array

Definition at line 1289 of file PtcDebug.php.

static _traceFunctionCalls (   $trace = null)
staticprotected

Function calls trace engine.

Parameters
array$tracethe php debug_backtrace( ) result

Definition at line 2138 of file PtcDebug.php.

static _watchCallback ( )
staticprotected

Callback function that checks if a given variable has changed.

Definition at line 928 of file PtcDebug.php.

static addCss (   $css)
static

Adds style properties to the floating panel styles array.

Parameters
string$csssome css to add

Definition at line 32 of file PtcDebug.php.

static addToBuffer (   $reference,
  $string,
  $statement = null 
)
static

Attaches a message to the end of the buffer array to add data based on a reference.

See Attaching Data To Messages

Parameters
string$referencea reference to look for ("$statement")
mixed$stringthe message to show
string$statementa new statement if required
Returns
true if the given reference is found, false otherwise

Definition at line 405 of file PtcDebug.php.

static bufferLog (   $string,
  $statement = null,
  $category = null 
)
static

Writes data to the messages panel.

See Logging Data

Parameters
mixed$stringthe string to pass
mixed$statementsome statement if required
string$categorya category for the messages panel

Definition at line 314 of file PtcDebug.php.

static bufferSql (   $string,
  $statement = null,
  $category = null 
)
static

Writes data to the sql panel.

See Logging Sql Queries

Parameters
mixed$stringthe string to pass
mixed$statementsome statement if required
string$categorya category for the sql panel

Definition at line 324 of file PtcDebug.php.

static checkReferer ( )
static

Checks if the debug "url_key" and "url_pass" are set on the referer url.

See check_referer

Returns
true if "url_key" and "url_pass" are in the referer url, otherwise false

Definition at line 37 of file PtcDebug.php.

static convertMemUsage (   $val,
  $precision = 2 
)
static

Convert memory_usage( ) into a readable format.

Parameters
float$valThe value to convert
int$precisionthe decimal points

Definition at line 364 of file PtcDebug.php.

static errorHandler (   $errno,
  $errstr,
  $errfile,
  $errline 
)
static

Handles php errors.

See Replacing Error Handler

Parameters
string$errnoerror number (php standards)
string$errstrerror string
string$errfileerror file
string$errlineerror line
Returns
true to prevent php default error handler to fire

Definition at line 378 of file PtcDebug.php.

static exceptionHandler (   $exception)
static

Exception handler, catches exceptions that are not in a try/catch block.

Parameters
object$exceptionthe exception object

Definition at line 392 of file PtcDebug.php.

static excludeFromTrace (   $functions)
static

Excludes functions from the function calls tracing engine.

Parameters
array  |  string$functionsthe function the exclude by their name

Definition at line 280 of file PtcDebug.php.

static findString (   $query,
  $path = null,
  $last = 1 
)
static

Searches files for a string inside a given folder recursively.

See Searching For A String Recursively

Parameters
string$querythe string to lok for
string$patha starting path to search recursively
int$lastcheck last result
Returns
an html table with all results

Definition at line 461 of file PtcDebug.php.

static getBuffer ( )
static

Returns the buffer array.

Returns
the buffer array

Definition at line 23 of file PtcDebug.php.

static getCoverage ( )
static

Retrieves the code coverage analysis data stored in the PtcDebug::$_finalCoverageData property.

Definition at line 27 of file PtcDebug.php.

static highlightFile (   $file,
  $line = null 
)
static

File highlighter that opens a popup window inspect source code.

See Inspecting Source Code

Parameters
string$filethe full path for the file
string$linethe line to be highlighted
Returns
the html output of the source code

Definition at line 523 of file PtcDebug.php.

static load (   $options = null)
static

Loads the debug interface and/or the console class if requested.

See Getting Started

Parameters
array$optionsarray of options, see PtcDebug::$ _defaultOptions

Definition at line 73 of file PtcDebug.php.

static processBuffer ( )
static

Processes the buffer to show the interface and/or the console messages.

Definition at line 427 of file PtcDebug.php.

static setErrorHandler (   $dieOnFatal = true)
static

Sets the error handler to be the debug class.

good for production with "$dieOnFatal" set to false. See Replacing Error Handler

Parameters
string$dieOnFataldie if fatal error occurs

Definition at line 57 of file PtcDebug.php.

static showSearchPopup (   $string,
  $path = null 
)
static

Shows the search popup window with the result.

Parameters
string$stringa search string to search for
string$patha start path where to search for a string recursively

Definition at line 2196 of file PtcDebug.php.

static startCoverage ( )
static

Starts the code coverage analysis utility to find executed lines.

See Code Coverage Analysis

Definition at line 217 of file PtcDebug.php.

static startTrace ( )
static

Starts the function calls trace utility.

See Function Calls Tracing

Definition at line 248 of file PtcDebug.php.

static stopCoverage ( )
static

Stops the code coverage analysis utility.

See Code Coverage Analysis

Definition at line 233 of file PtcDebug.php.

static stopTimer (   $reference = null,
  $precision = 1 
)
static

Monitors the execution of php code, or sql queries based on a reference.

See Execution Timing

Parameters
string$referencea reference to look for ("$statement")
string | numeric$precisionsec/ms
Returns
true if a given reference is found, otherwise false

Definition at line 334 of file PtcDebug.php.

static stopTrace ( )
static

Stops the function calls trace utility.

See Function Calls Tracing

Definition at line 264 of file PtcDebug.php.

static tickHandler ( )
static

The ticks handler to execute all tickable functions.

Definition at line 194 of file PtcDebug.php.

static watch (   $variableName,
  $callback = null 
)
static

Watches a variable that is in a declare(ticks=n); code block, for changes.

See Inspecting Variable Changes

Parameters
string$variableNamethe name of the variable to watch
string$callbacka callback function that retrieves the variable

Definition at line 290 of file PtcDebug.php.

Field Documentation

$_buffer = array( )
staticprotected

The debug buffer.

Definition at line 625 of file PtcDebug.php.

$_codeCoverage = false
staticprotected

Code coverage analysis property to start coverage.

Definition at line 653 of file PtcDebug.php.

$_consoleStarted = false
staticprotected

Decides if we should send the buffer to the PhpConsole class.

Definition at line 637 of file PtcDebug.php.

$_countTime = true
staticprotected

Exclude PtcDebug::$_buildBuffer from execution timing property.

Definition at line 649 of file PtcDebug.php.

$_coverageData = null
staticprotected

Code coverage analysis storage.

Definition at line 605 of file PtcDebug.php.

$_defaultOptions
staticprotected
Initial value:
= array
(
'url_key' => 'debug' ,
'url_pass' => 'true' ,
'replace_error_handler' => true ,
'error_reporting' => E_ALL ,
'catch_exceptions' => true ,
'check_referer' => false ,
'die_on_error' => true ,
'debug_console' => false ,
'allowed_ips' => null ,
'session_start' => false ,
'show_interface' => true ,
'set_time_limit' => null ,
'memory_limit' => null ,
'show_messages' => true ,
'show_globals' => true ,
'show_sql' => true ,
'show_w3c' => true,
'minified_html' => true ,
'trace_depth' => 10 ,
'max_dump_depth' => 6 ,
'panel_top' => '0px' ,
'panel_right' => '0px' ,
'default_category' => 'General' ,
'enable_inspector' => true ,
'code_coverage' => true,
'trace_functions' => true,
'exclude_categories' => array( 'Event Manager' , 'Autoloader' )
)

Default options for the debug class.

See Class Options

Definition at line 568 of file PtcDebug.php.

$_disableOpcode = true
staticprotected

Controlls when to disable opcode cache.

Definition at line 661 of file PtcDebug.php.

$_endTime = null
staticprotected

Application end time.

Definition at line 633 of file PtcDebug.php.

$_excludeFromTrace = array( )
staticprotected

Exclude functions from the function calls trace array.

Definition at line 665 of file PtcDebug.php.

$_excludeMethods =array( )
staticprotected

Array of methods excluded from the backtrace.

Definition at line 601 of file PtcDebug.php.

$_finalCoverageData = array( )
staticprotected

Final data array for the code coveage.

Definition at line 609 of file PtcDebug.php.

$_finalTraceData = array( )
staticprotected

Final data array for the function calls trace.

Definition at line 617 of file PtcDebug.php.

$_functionTrace = false
staticprotected

Function calls trace property to start the analysis.

Definition at line 657 of file PtcDebug.php.

$_options = array( )
staticprotected

Array with all options.

Definition at line 621 of file PtcDebug.php.

$_panelCss
staticprotected

Property that holds the css for the floating panel.

Definition at line 669 of file PtcDebug.php.

$_startTime = null
staticprotected

Application start time.

Definition at line 629 of file PtcDebug.php.

$_tickTime = 0
staticprotected

Tick execution time property.

Definition at line 645 of file PtcDebug.php.

$_traceData = null
staticprotected

Function calls tracing storage property.

Definition at line 613 of file PtcDebug.php.

$_watchedVars = array()
staticprotected

Array of watched variables declared.

Definition at line 641 of file PtcDebug.php.


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