Skip to content
Permalink
Browse files

Removing some of the singleton access in Debugger.

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

0 comments on commit ea7b323

Please sign in to comment.
You can’t perform that action at this time.