Exemplo n.º 1
0
 public static function _inspect_dive($data, $expand_objects, $max_depth, $depth = 0, $show_array_header = true)
 {
     $pad = ITUtility::pad($depth, '    ');
     if (is_string($data)) {
         if ('' === $data) {
             return "<strong>[empty string]</strong>";
         } else {
             return htmlspecialchars($data);
         }
     }
     if (is_bool($data)) {
         return $data ? '<strong>[boolean] true</strong>' : '<strong>[boolean] false</strong>';
     }
     if (is_null($data)) {
         return '<strong>null</strong>';
     }
     if (is_object($data)) {
         $class_name = get_class($data);
         $retval = "<strong>Object</strong> {$class_name}";
         if (!$expand_objects || $depth == $max_depth) {
             return $retval;
         }
         $vars = get_object_vars($data);
         if (empty($vars)) {
             $vars = '';
         } else {
             $vars = ITDebug::_inspect_dive($vars, $expand_objects, $max_depth, $depth, false);
         }
         $retval .= "{$vars}";
         return $retval;
     }
     if (is_array($data)) {
         $retval = $show_array_header ? '<strong>Array</strong>' : '';
         if (empty($data)) {
             return "{$retval}()";
         }
         if ($depth == $max_depth) {
             return "{$retval}( " . count($data) . " )";
         }
         $max = 0;
         foreach (array_keys($data) as $index) {
             if (strlen($index) > $max) {
                 $max = strlen($index);
             }
         }
         foreach ($data as $index => $val) {
             $spaces = ITUtility::pad($max - strlen($index), ' ');
             $retval .= "\n{$pad}" . htmlspecialchars($index) . "{$spaces}  <strong>=&gt;</strong> " . ITDebug::_inspect_dive($val, $expand_objects, $max_depth, $depth + 1);
         }
         return $retval;
     }
     return '<strong>[' . gettype($data) . ']</strong> ' . $data;
 }