Simplifying default Debugger output, fixes #4066

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6692 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-04-18 06:01:35 +00:00
parent 3e28323667
commit fc92ea039a
2 changed files with 25 additions and 61 deletions

View file

@ -357,7 +357,7 @@ class Debugger extends Object {
break; break;
case 'string': case 'string':
if (trim($var) == "") { if (trim($var) == "") {
return '"[empty string]"'; return '""';
} }
return '"' . h($var) . '"'; return '"' . h($var) . '"';
break; break;
@ -394,42 +394,25 @@ class Debugger extends Object {
* @access private * @access private
*/ */
function __object($var) { function __object($var) {
static $history = array();
$serialized = serialize($var);
array_push($history, $serialized);
$out = array(); $out = array();
if(is_object($var)) { if(is_object($var)) {
$className = get_class($var); $className = get_class($var);
$objectVars = get_object_vars($var); $objectVars = get_object_vars($var);
foreach($objectVars as $key => $value) { foreach($objectVars as $key => $value) {
$inline = null; if(is_object($value)) {
if(strpos($key, '_', 0) !== 0) { $value = get_class($value) . ' object';
$inline = "$className::$key = "; } elseif (is_array($value)) {
} $value = 'array';
} elseif ($value === null) {
if(is_object($value) || is_array($value)) { $value = 'NULL';
$serialized = serialize($value); } elseif (in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource'))) {
$value = Debugger::exportVar($value);
if(in_array($serialized, $history, true)) {
$value = ife(is_object($value), "*RECURSION* -> " . get_class($value), "*RECURSION*");
}
}
if(in_array(gettype($value), array('boolean', 'integer', 'double', 'string', 'array', 'resource', 'object', 'null'))) {
$out[] = "$className::$$key = " . Debugger::exportVar($value);
} else {
$out[] = "$className::$$key = " . var_export($value, true);
}
}
$objectMethods = get_class_methods($className);
foreach($objectMethods as $key => $value) {
if(strpos($value, '_', 0) !== 0) {
$out[] = "$className::$value()";
} }
$out[] = "$className::$$key = " . $value;
} }
} }
array_pop($history);
return join("\n", $out); return join("\n", $out);
} }
/** /**
@ -525,7 +508,6 @@ class Debugger extends Object {
$this->__data[] = compact('error', 'code', 'description', 'line', 'file', 'context', 'trace'); $this->__data[] = compact('error', 'code', 'description', 'line', 'file', 'context', 'trace');
break; break;
} }
} }
/** /**
* Verify that the application's salt has been changed from the default value * Verify that the application's salt has been changed from the default value

View file

@ -83,14 +83,14 @@ class DebuggerTest extends UnitTestCase {
$expected = 'ViewView::$base = NULL $expected = 'ViewView::$base = NULL
View::$here = NULL View::$here = NULL
View::$plugin = NULL View::$plugin = NULL
View::$name = "[empty string]" View::$name = ""
View::$action = NULL View::$action = NULL
View::$params = array() View::$params = array
View::$passedArgs = array() View::$passedArgs = array
View::$data = array() View::$data = array
View::$helpers = array("Html","Form") View::$helpers = array
View::$viewPath = "[empty string]" View::$viewPath = ""
View::$viewVars = array() View::$viewVars = array
View::$layout = "default" View::$layout = "default"
View::$layoutPath = NULL View::$layoutPath = NULL
View::$pageTitle = false View::$pageTitle = false
@ -100,39 +100,21 @@ class DebuggerTest extends UnitTestCase {
View::$subDir = NULL View::$subDir = NULL
View::$themeWeb = NULL View::$themeWeb = NULL
View::$cacheAction = false View::$cacheAction = false
View::$validationErrors = array() View::$validationErrors = array
View::$hasRendered = false View::$hasRendered = false
View::$loaded = array() View::$loaded = array
View::$modelScope = false View::$modelScope = false
View::$model = NULL View::$model = NULL
View::$association = NULL View::$association = NULL
View::$field = NULL View::$field = NULL
View::$fieldSuffix = NULL View::$fieldSuffix = NULL
View::$modelId = NULL View::$modelId = NULL
View::$uuids = array() View::$uuids = array
View::$__passedVars = array("viewVars","action","autoLayout","autoRender","ext","base","webroot","helpers","here","layout","name","pageTitle","layoutPath","viewPath","params","data","plugin","passedArgs","cacheAction") View::$__passedVars = array
View::$__scripts = array() View::$__scripts = array
View::$__paths = array() View::$__paths = array
View::$_log = NULL View::$_log = NULL
View::$webroot = NULL View::$webroot = NULL';
View::element()
View::render()
View::renderElement()
View::renderLayout()
View::renderCache()
View::getVars()
View::getVar()
View::addScript()
View::uuid()
View::entity()
View::set()
View::error()
View::Object()
View::toString()
View::requestAction()
View::dispatchMethod()
View::log()
View::cakeError()';
$result = str_replace(array("\t", "\r\n", "\n"), "", $result); $result = str_replace(array("\t", "\r\n", "\n"), "", $result);
$expected = str_replace(array("\t", "\r\n", "\n"), "", $expected); $expected = str_replace(array("\t", "\r\n", "\n"), "", $expected);
$this->assertEqual($result, $expected); $this->assertEqual($result, $expected);