Skip to content

[VarDumper] Fix dumping of SplObjectStorage #26999

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[VarDumper] Fix dumping of SplObjectStorage
  • Loading branch information
corphi authored and fabpot committed Apr 22, 2018
commit b2ac6b6fbfdcd6894538786b44bccd37afa7eed2
5 changes: 3 additions & 2 deletions src/Symfony/Component/VarDumper/Caster/SplCaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,11 @@ public static function castObjectStorage(\SplObjectStorage $c, array $a, Stub $s
$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(),
);
}

Expand Down
19 changes: 19 additions & 0 deletions src/Symfony/Component/VarDumper/Tests/Caster/SplCasterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,23 @@ public function provideCastSplDoublyLinkedList()
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);
}
}
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy