Krumo::_object PHP Method

_object() private static method

Render a dump for an object
private static _object ( mixed &$data, string $name )
$data mixed
$name string
    private static function _object(&$data, $name)
    {
        $reflection = new ReflectionObject($data);
        $properties = $reflection->getProperties();
        $childCount = count($properties);
        $collapsed = static::_isCollapsed(static::$_level, $childCount);
        // Setup the CSS classes depending on how many children there are
        if ($childCount > 0 && $collapsed) {
            $elementClasses = ' krumo-expand';
        } elseif ($childCount > 0) {
            $elementClasses = ' krumo-expand krumo-opened';
        } else {
            $elementClasses = '';
        }
        print "<li class=\"krumo-child\"> <div class=\"krumo-element {$elementClasses}\"";
        if (count($data) > 0) {
            print 'onClick="krumo.toggle(this);"';
        }
        print 'onMouseOver="krumo.over(this);" onMouseOut="krumo.out(this);">';
        $empty_str = '';
        if ($childCount == 0) {
            $empty_str = ' (empty)';
        }
        $class_name = get_class($data);
        print "<a class=\"krumo-name\">{$name}</a> <em class=\"krumo-type\">Object</em> ";
        print static::get_separator() . " <strong class=\"krumo-class\">{$class_name}</strong>{$empty_str}</div>";
        // If the object is an inherited exception, we want to print out the trace
        // so we add a bogus trace parameter that contains the trace array
        // Note: this is not required (will throw an error) for raw Exceptions
        if ($data instanceof Exception && $class_name !== "Exception") {
            $data->trace = $data->getTrace();
        }
        if ($properties) {
            static::_vars($data);
        }
        // Remove the trace we added
        if ($data instanceof Exception && $class_name !== "Exception") {
            unset($data->trace);
        }
        print "</li>";
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Dump information about a variable
  *
  * @param mixed $data
  * @param string $name
  * @access private
  * @static
  */
 private static function _dump(&$data, $name = '…')
 {
     // Highlight elements that have a space in their name.
     // Spaces are hard to see in the HTML and are hard to troubleshoot
     $name = Krumo::sanitize_name($name);
     // object
     if (is_object($data)) {
         return Krumo::_object($data, $name);
     }
     // array
     if (is_array($data)) {
         return Krumo::_array($data, $name);
     }
     // resource
     if (is_resource($data)) {
         return Krumo::_resource($data, $name);
     }
     // scalar
     if (is_string($data)) {
         return Krumo::_string($data, $name);
     }
     // float
     if (is_float($data)) {
         return Krumo::_float($data, $name);
     }
     // integer
     if (is_integer($data)) {
         return Krumo::_integer($data, $name);
     }
     // boolean
     if (is_bool($data)) {
         return Krumo::_boolean($data, $name);
     }
     // null
     if (is_null($data)) {
         return Krumo::_null($name);
     }
 }