PhpToolCase
[ class tree: PhpToolCase ] [ index: PhpToolCase ] [ all elements ]

Class: PtcDebug

Source Location: /workshop/PhpToolCase/current/PtcDebug.php

Class PtcDebug

Property Summary
static array   $_buffer   The debug buffer
static bool   $_consoleStarted   Decides if we should send the buffer to the PhpConsole class
static bool   $_countTime   Exclude $_buildBuffer from execution timing property
static array   $_defaultOptions   Default options for the debug class
static time   $_endTime   Application end time
static array   $_excludeMethods   Array of methods excluded from the backtrace
static bool   $_isLoaded   Checks if the PtcDebug::load() method has been called already
static array   $_options   Array with all options
static time   $_startTime   Application start time
static array   $_tickTime   Tick execution time property
static array   $_watchedVars   Array of watched variables declared

[ Top ]
Method Summary
static returns   addToBuffer()   Attaches a message to the end of the buffer array to add data based on a reference
static void   bufferLog()   Writes data to the messages panel
static void   bufferSql()   Writes data to the sql panel
static returns   checkReferer()   Checks if the debug "url_key" and "url_pass" are set on the referer url
static void   errorHandler()   Handles php errors
static void   exceptionHandler()   Exception handler, catches exceptions that are not in a try/catch block
static returns   highlightFile()   File highlighter that opens a popup window inspect source code
static void   load()   Loads the debug interface and/or the console class if requested
static void   processBuffer()   Processes the buffer to show the interface and/or the console messages
static void   setErrorHandler()   Sets the error handler to be the debug class. good for production with "$dieOnFatal" set to false
static resturns   stopTimer()   Monitors the execution of php code, or sql queries based on a reference
static void   watch()   Watches a variable that is in a declare(ticks=n); code block, for changes
static void   watchCallback()   Callback function that checks if a given variable has changed
static void   _buildBuffer()   Builds the buffer
static returns   _buildHtmlTable()   Builds the html log and sql tables
static void   _buildInnerVars()   Builds the inner vars div
static returns   _buildInterface()   Builds the debug interface
static returns   _buildMenu()   Builds the debug menu
static void   _buildMsgPanel()   Builds the log/sql panel
static void   _buildPhpInfo()   Formats phpinfo() function
static void   _buildTimerPanel()   Builds the timer panel
static void   _buildTraceLink()   Builds the link for the code highlighter popup
static void   _buildTraceTree()   Builds the tree for the links in the vars & config panel
static void   _buildVarsPanel()   Builds the vars panel
static void   _buildW3cPanel()   Builds the W3C panel
static void   _checkAccess()   Checks if a given ip has access
static void   _cleanBuffer()   Removes html entities from the buffer
static void   _compressHtml()   Compresses the html before render
static void   _debugConsole()   Sends the buffer to the PhpConsole class
static returns   _debugTrace()   Trace php as best as we can
static void   _disablePanels()   Controls which panels will be shown with $_GET variable "hidepanels"
static returns   _doDump()   Custom dump to properly format a given variable and make it more friendly to read
static returns   _findReference()   Finds a value in the buffer based on a reference (the "$statement")
static returns   _findWatchVar()   Retrieves the variable to watch from the "$GLOBALS"
static returns   _formatVar()   Evaluates the type of variable for output
static void   _includeCss()   Includes the css for the interface
static void   _includeJs()   Includes the javascript for the interface
static void   _lastError()   Gets the fatal error on shutdown
static returns   _menuLinks()   Builds the menu links
static returns   _msgType()   Checks message types
static void   _phpInfoArray()   Formats phpinfo() into an array
static void   _setSessionVars()   Sets session vars to control which panels will be shown
static returns   _sortBuffer()   Sorts the buffer

[ Top ]
Properties
static array   $_buffer = array() [line 1505]

The debug buffer

API Tags:
Access:  private


[ Top ]
static bool   $_consoleStarted = false [line 1522]

Decides if we should send the buffer to the PhpConsole class

API Tags:
Access:  private


[ Top ]
static bool   $_countTime = true [line 1543]

Exclude $_buildBuffer from execution timing property

API Tags:
Access:  private


[ Top ]
static array   $_defaultOptions = array
(
'url_key' => 'debug',// the key to pass to the url to turn on debug
'url_pass' => 'true',// the pass to turn on debug
'replace_error_handler' => true,// replace default php error handler
'error_reporting' => E_ALL,// error reporting flag
'catch_exceptions' => true,// sets exception handler to be this class method
'check_referer' => false,// check referer for key and pass(good for ajax debugging)
'die_on_error' => true,// die if fatal error occurs(with this class error handler)
'debug_console' => false,// only for Chrome,show messages in console(phpConsole needed)
'allowed_ips' => null,// restrict access with ip's
'session_start' => false,// start session for persistent debugging
'show_interface' => true,// show the interface(false to debug in console only)
'enable_inspector' => true,// enable variables inspector, use declare(ticks=n); in code block
'declare_ticks' => false,// declare ticks glabally with value of 1
'set_time_limit' => null,// set php execution time limit
'memory_limit' => null,// set php memory size
'show_messages' => true,// show messages panel
'show_globals' => true,// show global variables in vars panel
'show_sql' => true,// show sql panel
'trace_depth' => 10,// maximum depth for the backtrace
'max_dump_depth' => 6,// maximum depth for the dump function
'default_category' => 'General'
)
[line 394]

Default options for the debug class

API Tags:
Access:  protected

Information Tags:
Tutorial:  CLASS OPTIONS

[ Top ]
static time   $_endTime = null [line 1517]

Application end time

API Tags:
See:  PtcDebug::stopTimer()
Access:  private


[ Top ]
static array   $_excludeMethods = array('bufferLog','bufferSql') [line 422]

Array of methods excluded from the backtrace

API Tags:
Access:  protected


[ Top ]
static bool   $_isLoaded = false [line 1538]

Checks if the PtcDebug::load() method has been called already

API Tags:
Access:  private


[ Top ]
static array   $_options = array() [line 1500]

Array with all options

API Tags:
Access:  private


[ Top ]
static time   $_startTime = null [line 1511]

Application start time

API Tags:
See:  PtcDebug::stopTimer()
Access:  private


[ Top ]
static array   $_tickTime [line 1533]

Tick execution time property

API Tags:
See:  watch_var()
Access:  private


[ Top ]
static array   $_watchedVars = array() [line 1527]

Array of watched variables declared

API Tags:
Access:  private


[ Top ]
Methods
static method addToBuffer  [line 304]

  static returns addToBuffer( string $reference, mixed $string, [string $statement = null]  )

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

Parameters:
string   $reference:  a reference to look for ("$statement")
mixed   $string:  the message to show
string   $statement:  a new statement if required

API Tags:
Return:  true if the given reference is found, false otherwise
See:  add_to_log()
Access:  public

Information Tags:
Tutorial:  ADDING DATA TO THE LOG

[ Top ]
static method bufferLog  [line 222]

  static void bufferLog( mixed $string, [mixed $statement = null], [string $category = null]  )

Writes data to the messages panel

Parameters:
mixed   $string:  the string to pass
mixed   $statement:  some statement if required
string   $category:  a category for the messages panel

API Tags:
See:  log_msg()
Access:  public

Information Tags:
Tutorial:  Logging messages

[ Top ]
static method bufferSql  [line 234]

  static void bufferSql( mixed $string, [mixed $statement = null], [string $category = null]  )

Writes data to the sql panel

Parameters:
mixed   $string:  the string to pass
mixed   $statement:  some statement if required
string   $category:  a category for the sql panel

API Tags:
See:  log_sql()
Access:  public

Information Tags:
Tutorial:  Logging sql queries

[ Top ]
static method checkReferer  [line 20]

  static returns checkReferer( )

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


API Tags:
Return:  true if "url_key" and "url_pass" are in the referer url, otherwise false
Access:  public


[ Top ]
static method errorHandler  [line 275]

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

Handles php errors

Parameters:
string   $errno:  error number (php standards)
string   $errstr:  error string
string   $errfile:  error file
string   $errline:  error line

API Tags:
See:  PtcDebug::setErrorHandler()
Access:  public


[ Top ]
static method exceptionHandler  [line 289]

  static void exceptionHandler( object $exception  )

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

Parameters:
object   $exception:  the exception object

API Tags:
Access:  public


[ Top ]
static method highlightFile  [line 346]

  static returns highlightFile( string $file, [string $line = null]  )

File highlighter that opens a popup window inspect source code

Parameters:
string   $file:  the full path for the file
string   $line:  the line to be highlighted

API Tags:
Return:  the html output of highlight_file()
Access:  public

Information Tags:
Tutorial:  INSPECTING SOURCE CODE

[ Top ]
static method load  [line 57]

  static void load( [array $options = null]  )

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

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

API Tags:
Access:  public

Information Tags:
Tutorial:  GETTING STARTED

[ Top ]
static method processBuffer  [line 327]

  static void processBuffer( )

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


API Tags:
See:  PtcDebug::load()
Access:  public


[ Top ]
static method setErrorHandler  [line 40]

  static void setErrorHandler( [string $dieOnFatal = true]  )

Sets the error handler to be the debug class. good for production with "$dieOnFatal" set to false

Parameters:
string   $dieOnFatal:  die if fatal error occurs

API Tags:
Access:  public

Information Tags:
Tutorial:  REPLACING ERROR HANDLER

[ Top ]
static method stopTimer  [line 246]

  static resturns stopTimer( [string $reference = null], [string|numeric $precision = 1]  )

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

Parameters:
string   $reference:  a reference to look for ("$statement")
string|numeric   $precision:  sec/ms

API Tags:
Return:  true if a given reference is found, otherwise false
See:  stop_timer()
Access:  public

Information Tags:
Tutorial:  EXECUTION TIMING

[ Top ]
static method watch  [line 170]

  static void watch( string $variableName  )

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

Parameters:
string   $variableName:  the name of the variable to watch

API Tags:
See:  watch_var()
Access:  public

Information Tags:
Tutorial:  INSPECTING VARIABLE CHANGES

[ Top ]
static method watchCallback  [line 190]

  static void watchCallback( )

Callback function that checks if a given variable has changed


API Tags:
Access:  public


[ Top ]
static method _buildBuffer  [line 511]

  static void _buildBuffer( string $type, mixed $string, [mixed $statement = null], [string $category = null]  )

Builds the buffer

Parameters:
string   $type:  log/sql
mixed   $string:  the string to pass
mixed   $statement:  some statement preceding the string
string   $category:  a category for the message

API Tags:
Access:  protected


[ Top ]
static method _buildHtmlTable  [line 999]

  static returns _buildHtmlTable( string $type  )

Builds the html log and sql tables

Parameters:
string   $type:  sql|log

API Tags:
Return:  the html table data
Access:  protected


[ Top ]
static method _buildInnerVars  [line 1216]

  static void _buildInnerVars( string $panelId, string $linkTitle, string $array  )

Builds the inner vars div

Parameters:
string   $panelId:  the id of the panel to show/hide
string   $linkTitle:  the title of the link
string   $array:  array of parameters

API Tags:
Access:  protected


[ Top ]
static method _buildInterface  [line 911]

  static returns _buildInterface( )

Builds the debug interface


API Tags:
Return:  the html with interface
Access:  protected


[ Top ]
static method _buildMenu  [line 933]

  static returns _buildMenu( )

Builds the debug menu


API Tags:
Return:  the html menu compressed
Access:  protected


[ Top ]
static method _buildMsgPanel  [line 1151]

  static void _buildMsgPanel( $type $type, $panelId $panelId  )

Builds the log/sql panel

Parameters:
$type   $type:  log or sql
$panelId   $panelId:  some id for the panel

API Tags:
Access:  protected


[ Top ]
static method _buildPhpInfo  [line 1255]

  static void _buildPhpInfo( )

Formats phpinfo() function


API Tags:
Access:  protected


[ Top ]
static method _buildTimerPanel  [line 1162]

  static void _buildTimerPanel( )

Builds the timer panel


API Tags:
Access:  protected


[ Top ]
static method _buildTraceLink  [line 1105]

  static void _buildTraceLink( string $file, [string $line = null]  )

Builds the link for the code highlighter popup

Parameters:
string   $file:  the full path to the file
string   $line:  the line to be highlighted

API Tags:
Access:  protected


[ Top ]
static method _buildTraceTree  [line 1126]

  static void _buildTraceTree( mixed $var, [string $className = null], [string $styleColor = null]  )

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

Parameters:
mixed   $var:  the variable
string   $className:  a css class
string   $styleColor:  the color for

API Tags:
Access:  protected


[ Top ]
static method _buildVarsPanel  [line 1174]

  static void _buildVarsPanel( )

Builds the vars panel


API Tags:
Access:  protected


[ Top ]
static method _buildW3cPanel  [line 1226]

  static void _buildW3cPanel( )

Builds the W3C panel


API Tags:
Access:  protected


[ Top ]
static method _checkAccess  [line 461]

  static void _checkAccess( [string|array $allowedIps = null]  )

Checks if a given ip has access

Parameters:
string|array   $allowedIps:  the ip's that are allowed

API Tags:
Access:  protected


[ Top ]
static method _cleanBuffer  [line 1548]

  static void _cleanBuffer( string $var  )

Removes html entities from the buffer

Parameters:
string   $var:  some string

API Tags:
Access:  private


[ Top ]
static method _compressHtml  [line 1465]

  static void _compressHtml( $html  )

Compresses the html before render

Parameters:
   $html: 

API Tags:
Access:  protected


[ Top ]
static method _debugConsole  [line 426]

  static void _debugConsole( )

Sends the buffer to the PhpConsole class


API Tags:
Access:  protected


[ Top ]
static method _debugTrace  [line 859]

  static returns _debugTrace( [ $depth = NULL]  )

Trace php as best as we can

Parameters:
   $depth: 

API Tags:
Return:  the trace without the methods in the _excludeMethods property
Access:  protected


[ Top ]
static method _disablePanels  [line 485]

  static void _disablePanels( )

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


API Tags:
Access:  protected


[ Top ]
static method _doDump  [line 653]

  static returns _doDump( &$var, [mixed $varName = NULL], [string $indent = NULL], [string $reference = NULL], [ $depth = 0], mixed $var  )

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

Parameters:
mixed   $var:  the string to pass
mixed   $varName:  some statement preceding the variable
string   $indent:  uses "|" as indents by default
string   $reference:  a reference to prevent recursion
   &$var: 
   $depth: 

API Tags:
Return:  the html output with the variable
Access:  protected


[ Top ]
static method _findReference  [line 620]

  static returns _findReference( string $reference, [numeric $type = 1]  )

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

Parameters:
string   $reference:  the reference to look for
numeric   $type:  "1" to time execution, "2" to attach data to a message

API Tags:
Return:  the array if the given reference is found in the buffer
Access:  protected


[ Top ]
static method _findWatchVar  [line 591]

  static returns _findWatchVar( string $variableName  )

Retrieves the variable to watch from the "$GLOBALS"

Parameters:
string   $variableName:  the name of the variable to find

API Tags:
Return:  the watched variable if found, otherwise null
Access:  protected


[ Top ]
static method _formatVar  [line 572]

  static returns _formatVar( $var, mixed $string  )

Evaluates the type of variable for output

Parameters:
mixed   $string:  the variable to pass
   $var: 

API Tags:
Return:  the html output with the variable content
Access:  protected


[ Top ]
static method _includeCss  [line 1268]

  static void _includeCss( )

Includes the css for the interface


API Tags:
Access:  protected


[ Top ]
static method _includeJs  [line 1327]

  static void _includeJs( )

Includes the javascript for the interface


API Tags:
Access:  protected


[ Top ]
static method _lastError  [line 894]

  static void _lastError( )

Gets the fatal error on shutdown


API Tags:
Access:  protected


[ Top ]
static method _menuLinks  [line 953]

  static returns _menuLinks( string $Id, string $title, string $text  )

Builds the menu links

Parameters:
string   $Id:  the panel id
string   $title:  the panel title
string   $text:  the text for the link

API Tags:
Return:  the html anchor tag
Access:  protected


[ Top ]
static method _msgType  [line 965]

  static returns _msgType( [string|numeric $msg = NULL]  )

Checks message types

Parameters:
string|numeric   $msg:  php standards

API Tags:
Return:  the message type as a readable string
Access:  protected


[ Top ]
static method _phpInfoArray  [line 1474]

  static void _phpInfoArray( )

Formats phpinfo() into an array


API Tags:
Access:  protected


[ Top ]
static method _setSessionVars  [line 476]

  static void _setSessionVars( )

Sets session vars to control which panels will be shown


API Tags:
Access:  protected


[ Top ]
static method _sortBuffer  [line 842]

  static returns _sortBuffer( )

Sorts the buffer


API Tags:
Return:  the sorted buffer array
Access:  protected


[ Top ]

Documentation generated on Fri, 30 Aug 2013 15:28:57 +0200 by phpDocumentor 1.4.3