/** * Render a dump for the properties of an array or objeect * * @param mixed &$data * @access private * @static */ private static function _vars(&$data) { $_is_object = is_object($data); // test for references in order to // prevent endless recursion loops $_recursion_marker = Dumper::_marker(); if ($_is_object) { if (($hash = spl_object_hash($data)) && isset(self::$objectRecursionProtection[$hash])) { $_r = self::$objectRecursionProtection[$hash]; } else { $_r = NULL; } } else { $_r = isset($data[$_recursion_marker]) ? $data[$_recursion_marker] : null; } // recursion detected if ($_r > 0) { return Dumper::_recursion(); } // stain it Dumper::_hive($data); // render it $collapsed = Dumper::_isCollapsed(self::$_level, count($data) - 1); if ($collapsed) { $collapse_style = 'style="display: none;"'; } else { $collapse_style = ''; } print "<div class=\"dumper-nest\" {$collapse_style}>"; print "<ul class=\"dumper-node\">"; // we're descending one level deeper self::$_level++; // Object?? - use Reflection if ($_is_object) { $reflection = new ReflectionObject($data); $properties = $reflection->getProperties(); foreach ($properties as $property) { $prefix = null; $setAccessible = false; if ($property->isPrivate()) { $setAccessible = true; $prefix = 'private'; } elseif ($property->isProtected()) { $setAccessible = true; $prefix = 'protected'; } elseif ($property->isPublic()) { $prefix = 'public'; } $name = $property->getName(); if ($setAccessible) { $property->setAccessible(true); } $value = $property->getValue($data); Dumper::_dump($value, "<span>{$prefix}</span> {$name}"); if ($setAccessible) { $property->setAccessible(false); } } } else { // keys $keys = array_keys($data); // iterate foreach ($keys as $k) { // skip marker if ($k === $_recursion_marker) { continue; } // get real value $v =& $data[$k]; Dumper::_dump($v, $k); } } print "</ul>\n</div>"; self::$_level--; }