Removing some of the singleton access in Debugger.

This commit is contained in:
Mark Story 2010-04-19 00:15:56 -04:00
parent 2bf9504cfb
commit ea7b32347d

View file

@ -208,8 +208,7 @@ class Debugger {
* @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class * @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class
*/ */
public static function dump($var) { public static function dump($var) {
$_this =& Debugger::getInstance(); pr(self::exportVar($var));
pr($_this->exportVar($var));
} }
/** /**
@ -223,9 +222,8 @@ class Debugger {
* @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class * @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class
*/ */
public static function log($var, $level = LOG_DEBUG) { public static function log($var, $level = LOG_DEBUG) {
$_this =& Debugger::getInstance(); $source = self::trace(array('start' => 1)) . "\n";
$source = $_this->trace(array('start' => 1)) . "\n"; CakeLog::write($level, "\n" . $source . self::exportVar($var));
CakeLog::write($level, "\n" . $source . $_this->exportVar($var));
} }
/** /**
@ -251,7 +249,7 @@ class Debugger {
if (empty($line)) { if (empty($line)) {
$line = '??'; $line = '??';
} }
$path = $_this->trimPath($file); $path = self::trimPath($file);
$info = compact('code', 'description', 'file', 'line'); $info = compact('code', 'description', 'file', 'line');
if (!in_array($info, $_this->errors)) { if (!in_array($info, $_this->errors)) {
@ -297,7 +295,7 @@ class Debugger {
$data = compact( $data = compact(
'level', 'error', 'code', 'helpID', 'description', 'file', 'path', 'line', 'context' 'level', 'error', 'code', 'helpID', 'description', 'file', 'path', 'line', 'context'
); );
echo $_this->_output($data); echo self::_output($data);
if (Configure::read('log')) { if (Configure::read('log')) {
$tpl = $_this->_templates['log']['error']; $tpl = $_this->_templates['log']['error'];
@ -385,7 +383,7 @@ class Debugger {
} else { } else {
$tpl = $_this->_templates['base']['traceLine']; $tpl = $_this->_templates['base']['traceLine'];
} }
$trace['path'] = Debugger::trimPath($trace['file']); $trace['path'] = self::trimPath($trace['file']);
$trace['reference'] = $reference; $trace['reference'] = $reference;
unset($trace['object'], $trace['args']); unset($trace['object'], $trace['args']);
$back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}')); $back[] = String::insert($tpl, $trace, array('before' => '{:', 'after' => '}'));
@ -471,7 +469,6 @@ class Debugger {
* @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class * @link http://book.cakephp.org/view/1191/Using-the-Debugger-Class
*/ */
public static function exportVar($var, $recursion = 0) { public static function exportVar($var, $recursion = 0) {
$_this =& Debugger::getInstance();
switch (strtolower(gettype($var))) { switch (strtolower(gettype($var))) {
case 'boolean': case 'boolean':
return ($var) ? 'true' : 'false'; return ($var) ? 'true' : 'false';
@ -487,17 +484,17 @@ class Debugger {
return '"' . h($var) . '"'; return '"' . h($var) . '"';
break; break;
case 'object': case 'object':
return get_class($var) . "\n" . $_this->__object($var); return get_class($var) . "\n" . self::_object($var);
case 'array': case 'array':
$out = "array("; $out = "array(";
$vars = array(); $vars = array();
foreach ($var as $key => $val) { foreach ($var as $key => $val) {
if ($recursion >= 0) { if ($recursion >= 0) {
if (is_numeric($key)) { if (is_numeric($key)) {
$vars[] = "\n\t" . $_this->exportVar($val, $recursion - 1); $vars[] = "\n\t" . self::exportVar($val, $recursion - 1);
} else { } else {
$vars[] = "\n\t" .$_this->exportVar($key, $recursion - 1) $vars[] = "\n\t" . self::exportVar($key, $recursion - 1)
. ' => ' . $_this->exportVar($val, $recursion - 1); . ' => ' . self::exportVar($val, $recursion - 1);
} }
} }
} }
@ -521,10 +518,9 @@ class Debugger {
* *
* @param string $var Object to convert * @param string $var Object to convert
* @return string * @return string
* @access private
* @see Debugger::exportVar() * @see Debugger::exportVar()
*/ */
function __object($var) { protected static function _object($var) {
$out = array(); $out = array();
if (is_object($var)) { if (is_object($var)) {