Skip to content

Commit

Permalink
Merge pull request #206 from Slamdunk/hotfix/debug-export-arrayiterator
Browse files Browse the repository at this point in the history
Debug::export ArrayIterator dumps the internal storage variable
  • Loading branch information
guilhermeblanco committed Jan 25, 2013
2 parents f44d98d + bd64f3a commit db84fc1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/Doctrine/Common/Util/Debug.php
Expand Up @@ -104,7 +104,7 @@ public static function export($var, $maxDepth)
$return->__PROXY_INITIALIZED__ = $var->__isInitialized();
}

if ($var instanceof \ArrayObject) {
if ($var instanceof \ArrayObject || $var instanceof \ArrayIterator) {
$return->__STORAGE__ = self::export($var->getArrayCopy(), $maxDepth - 1);
}

Expand Down
7 changes: 6 additions & 1 deletion tests/Doctrine/Tests/Common/Util/DebugTest.php
Expand Up @@ -25,11 +25,16 @@ public function testExportDateTime()
$this->assertEquals( "DateTime", $var->__CLASS__ );
}

public function testExportArrayObject()
public function testExportArrayTraversable()
{
$obj = new \ArrayObject(array('foobar'));

$var = Debug::export($obj, 2);
$this->assertContains('foobar', $var->__STORAGE__);

$it = new \ArrayIterator(array('foobar'));

$var = Debug::export($it, 5);
$this->assertContains('foobar', $var->__STORAGE__);
}
}

0 comments on commit db84fc1

Please sign in to comment.