function Test_debug() { ob_start(); Ak::debug($this->AkTestingObjectInspectionChildInstance); $debug_str = ob_get_contents(); ob_end_clean(); $this->assertFalse($debug_str == '', 'Ak::debug not working properly'); }
/** * Outputs debug info given a PHP resource (vars, objects, * arrays...) * * @access public * @static * @param mixed $data Data to debug. It can be an object, array, * resource.. * @return void Prints debug info. */ function debug($data, $_functions = 0) { if (!AK_DEBUG && !AK_DEV_MODE) { return; } if ($_functions != 0) { $sf = 1; } else { $sf = 0; } if (is_object($data) && method_exists($data, 'debug')) { echo AK_CLI ? "\n------------------------------------\nEntering on " . get_class($data) . " debug() method\n\n" : "<hr /><h2>Entering on " . get_class($data) . " debug() method</h2>"; if (!empty($data->__activeRecordObject)) { $data->toString(true); } $data->debug(); return; } if (isset($data)) { if (is_array($data) || is_object($data)) { if (count($data)) { echo AK_CLI ? "/--\n" : "<ol>\n"; while (list($key, $value) = each($data)) { $type = gettype($value); if ($type == "array" || $type == "object") { ob_start(); Ak::debug($value, $sf); $lines = explode("\n", ob_get_clean() . "\n"); foreach ($lines as $line) { echo "\t" . $line . "\n"; } } elseif (eregi("function", $type)) { if ($sf) { AK_CLI ? printf("\t* (%s) %s:\n", $type, $key, $value) : printf("<li>(%s) <b>%s</b> </li>\n", $type, $key, $value); } } else { if (!$value) { $value = "(none)"; } AK_CLI ? printf("\t* (%s) %s = %s\n", $type, $key, $value) : printf("<li>(%s) <b>%s</b> = %s</li>\n", $type, $key, $value); } } echo AK_CLI ? "\n--/\n" : "</ol>fin.\n"; } else { echo "(empty)"; } } } }
function debug ($data = 'active_record_class', $_functions=0) { if(!AK_DEBUG && !AK_DEV_MODE){ return; } $data = $data == 'active_record_class' ? (AK_PHP5 ? clone($this) : $this) : $data; if($_functions!=0) { $sf=1; } else { $sf=0 ; } if (isset ($data)) { if (is_array($data) || is_object($data)) { if (count ($data)) { echo AK_CLI ? "/--\n" : "<ol>\n"; while (list ($key,$value) = each ($data)) { if($key{0} == '_'){ continue; } $type=gettype($value); if ($type=="array") { AK_CLI ? printf ("\t* (%s) %s:\n",$type, $key) : printf ("<li>(%s) <b>%s</b>:\n",$type, $key); ob_start(); Ak::debug ($value,$sf); $lines = explode("\n",ob_get_clean()."\n"); foreach ($lines as $line){ echo "\t".$line."\n"; } }elseif($type == "object"){ if(method_exists($value,'hasColumn') && $value->hasColumn($key)){ $value->toString(true); AK_CLI ? printf ("\t* (%s) %s:\n",$type, $key) : printf ("<li>(%s) <b>%s</b>:\n",$type, $key); ob_start(); Ak::debug ($value,$sf); $lines = explode("\n",ob_get_clean()."\n"); foreach ($lines as $line){ echo "\t".$line."\n"; } } }elseif (eregi ("function", $type)) { if ($sf) { AK_CLI ? printf ("\t* (%s) %s:\n",$type, $key, $value) : printf ("<li>(%s) <b>%s</b> </li>\n",$type, $key, $value); } } else { if (!$value) { $value="(none)"; } AK_CLI ? printf ("\t* (%s) %s = %s\n",$type, $key, $value) : printf ("<li>(%s) <b>%s</b> = %s</li>\n",$type, $key, $value); } } echo AK_CLI ? "\n--/\n" : "</ol>fin.\n"; } else { echo "(empty)"; } } } }