Fix errors with recursion in debug()

Fixes #3102
This commit is contained in:
mark_story 2012-08-08 22:30:27 -04:00
parent 476bd80644
commit dca050fbd6
2 changed files with 16 additions and 1 deletions

View file

@ -477,6 +477,16 @@ TEXT;
$this->assertEquals($expected, $output);
}
/**
* Test that exportVar() doesn't loop through recursive structures.
*
* @return void
*/
public function testExportVarRecursion() {
$output = Debugger::exportVar($GLOBALS);
$this->assertContains("'GLOBALS' => [recursion]", $output);
}
/**
* test trace exclude
*

View file

@ -542,9 +542,14 @@ class Debugger {
if ($depth >= 0) {
foreach ($var as $key => $val) {
if ($val !== $var) {
$val = self::_export($val, $depth, $indent);
} else {
$val = '[recursion]';
}
$vars[] = $break . self::exportVar($key) .
' => ' .
self::_export($val, $depth, $indent);
$val;
}
} else {
$vars[] = $break . '[maximum depth reached]';