Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_Debug class

• Introduction

Debugger class.

• Class synopsis

AMI_Debug {
/* Methods */
// Adds benchmark.
public static bench ( string $label ) returns void;
// Dumps entity structure to debug output.
public static dump ( mixed $entity, [ string $title = '' ], [ $aOptions = array('nesting' => 2, 'method' => 'print_r') ] ) returns void;
// Returns class parents as array.
public static getClassParents ( mixed $object ) returns array;
// Returns entity full dump as string.
public static getDumpAsString ( mixed $entity, [ callback $callback = 'print_r' ], [ $aArgs = array() ] ) returns string;
// Returns trace HTML as string.
public static getTraceAsString ( [ $aTrace = null ] ) returns string;
// Printss class parents.
public static printClassParents ( mixed $object ) returns void;
// Dumps backtrace to debug output.
public static trace ( [ $aTrace = null ] ) returns void;
// Writes string to debug output.
public static write ( string $string ) returns void;
}

• Class Details

Use short aliases from examples i.e. d::vd() instead of AMI_Debug::dump() when available.
Tags:
see d

• Class Methods

// Adds benchmark.
public static bench ( string $label ) returns void;
  • string $label
    Label
Each benchmark contains:
  • time difference from previous bench to itself;
  • time difference from script start time to itself;
  • memory usage difference from previous bench to itself;
  • peak memory usage on registering bechmark;
  • bechmark caller (file, line number).
Example:
// Dumps entity structure to debug output.
public static dump ( mixed $entity, [ string $title = '' ], [ $aOptions = array('nesting' => 2, 'method' => 'print_r') ] ) returns void;
  • mixed $entity
    Entity to dump
  • string $title
    Entity title
  • array $aOptions
    Array containing dump options:
    • 'nesting' - max nesting level for arrays (2 by default, 0 for no limits);
    • 'method' - dump method, 'print_r'|'var_dump'|'var_export' ('print_r' by default);
    • 'max_count' - maximum dumps per title (none by default);
    • 'html_ent' = use htmlentities() (since 6.0.6);
All objects are replaced by its class names,
array depth limitation ($aOptions['nesting']) is supported.
Tags:
see d::pr()
see d::ve()
see d::vd()
// Returns class parents as array.
public static getClassParents ( mixed $object ) returns array;
  • mixed $object
    The tested object or class name
Tags:
since 5.14.4
// Returns entity full dump as string.
public static getDumpAsString ( mixed $entity, [ callback $callback = 'print_r' ], [ $aArgs = array() ] ) returns string;
  • mixed $entity
    Entity to dump
  • callback $callback
    Dump callback ('print_r'|'var_dump'|'var_export'|'debug_zval_dump') or anything else
  • array $aArgs
    Callback arguments
  Example:
  •  echo d::getDumpAsString(array('k000''k001' => array('k010' => array('k100' => array(123)))));
will output:
 Array(
     [0] => k000
     [k001] => Array(
             [k010] => Array(
                     [k100] => Array(
                             [0] => 1
                             [1] => 2
                             [2] => 3
                         )
                 )
         )
 )
// Returns trace HTML as string.
public static getTraceAsString ( [ $aTrace = null ] ) returns string;
  • array $aTrace
    Array having the same structure as debug_backtrace() result
  Example:
  •  echo d::getTraceAsString();
// Printss class parents.
public static printClassParents ( mixed $object ) returns void;
  • mixed $object
    The tested object or class name
Tags:
since 5.14.4
// Dumps backtrace to debug output.
public static trace ( [ $aTrace = null ] ) returns void;
  • array $aTrace
    Array having the same structure as debug_backtrace() result
// Writes string to debug output.
public static write ( string $string ) returns void;
  • string $string
    String to write
  Example:
  •  d::w('<h1>Some debug string</h1>');