[VarDumper] Fix dumping of SplObjectStorage

This commit is contained in:
Philipp Cordes 2018-04-21 15:09:06 +02:00 committed by Fabien Potencier
parent b97a4ae031
commit b2ac6b6fbf
2 changed files with 22 additions and 2 deletions

View File

@ -86,10 +86,11 @@ class SplCaster
$storage = array();
unset($a[Caster::PREFIX_DYNAMIC."\0gcdata"]); // Don't hit https://bugs.php.net/65967
foreach (clone $c as $obj) {
$clone = clone $c;
foreach ($clone as $obj) {
$storage[spl_object_hash($obj)] = array(
'object' => $obj,
'info' => $c->getInfo(),
'info' => $clone->getInfo(),
);
}

View File

@ -40,4 +40,23 @@ EOTXT;
array(\SplDoublyLinkedList::IT_MODE_LIFO | \SplDoublyLinkedList::IT_MODE_DELETE, 'IT_MODE_LIFO | IT_MODE_DELETE'),
);
}
public function testCastObjectStorageIsntModified()
{
$var = new \SplObjectStorage();
$var->attach(new \stdClass());
$var->rewind();
$current = $var->current();
$this->assertDumpMatchesFormat('%A', $var);
$this->assertSame($current, $var->current());
}
public function testCastObjectStorageDumpsInfo()
{
$var = new \SplObjectStorage();
$var->attach(new \stdClass(), new \DateTime());
$this->assertDumpMatchesFormat('%ADateTime%A', $var);
}
}