Ejemplo n.º 1
0
function baz($a, $b)
{
    echo '<h2>Class inhertance</h2>';
    $foo = new Foo();
    dump($foo);
    echo '<h2>PHP Global variables</h2>';
    dump(array('$_SERVER' => $_SERVER, '$_REQUEST' => $_REQUEST));
    echo '<h2>Exception</h2>';
    dump(new ErrorException('Dummy exception'));
    echo '<h2>Debug backtrace</h2>';
    dump(debug_backtrace());
    echo '<h2>Debug backtrace (processed)</h2>';
    dump(Dump::backtrace(debug_backtrace()));
    echo '<h2>Recursion</h2>';
    //array
    $a = array('a', 'b');
    $a['c'] =& $a;
    //objects
    $b = new DummyClass();
    $b->field = $b;
    $b->field->field =& $b;
    dump($a, $b);
    echo '<h2>Test source code</h2>';
    echo Dump::source(file_get_contents(__FILE__));
}
Ejemplo n.º 2
0
 private function _render_exception($name, Exception $e, $level = 0)
 {
     $children = array();
     //Basic info about the exception
     $path = Dump::clean_path($e->getFile());
     $message = Dump::clean_path($e->getMessage());
     if ($this->html) {
         $children[] = $this->html_element('div', array('class' => 'dump-exception'), htmlspecialchars($message));
     }
     //Source code
     if ($this->html) {
         $backtrace = Dump::backtrace($e->getTrace());
         foreach ($backtrace as $step) {
             if ($step['file'] == $path && $step['line'] == $e->getLine()) {
                 $source = $step['source'];
                 break;
             }
         }
         if (!isset($source)) {
             $source = self::get_source($e->getFile(), $e->getLine());
         }
         if (!empty($source)) {
             $children[] = $this->_render_source_code('Source', $source, $path, $e->getLine());
         }
     } else {
         $children[] = $this->_render_item('Location', '', $path . ':' . $e->getLine(), $level + 1);
         $backtrace = Dump::backtrace_small($e->getTrace());
     }
     //Context and data
     if (method_exists($e, 'getContext')) {
         $context = $e->getContext();
         $children[] = $this->_render('Context', $context, $level + 1);
     }
     if (method_exists($e, 'getData')) {
         $data = $e->getData();
         $children[] = $this->_render('Data', $data, $level + 1);
     }
     //Backtrace (en modo texto)
     if (!is_array($backtrace)) {
         $children[] = $this->_render_item('Backtrace', '', $backtrace, $level + 1);
     }
     //Fields
     $children[] = $this->_render_vars('Fields', $e, $level + 1, '', ['message']);
     //Backtrace
     if (is_array($backtrace)) {
         $children[] = $this->_render_vars('Backtrace', $backtrace, $level);
     }
     if ($level == 0) {
         return $this->_render_item(get_class($e), '', strip_tags($message), $level, '', '', $children, 'exception');
     } else {
         return $this->_render_item($name, get_class($e), strip_tags($message), $level, '', '', $children, 'exception');
     }
 }