From 06213c23ca1bc25ed860bc3a0bd5bbdfce8e7898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Wed, 29 Mar 2023 18:19:39 +0200 Subject: [PATCH] clone Ds\Collection --- src/Tracy/Dumper/Exposer.php | 2 +- tests/Tracy/Dumper.toText().specials.ds.phpt | 22 ++++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/Tracy/Dumper/Exposer.php b/src/Tracy/Dumper/Exposer.php index 04a5d4f60..5a7d5c0e5 100644 --- a/src/Tracy/Dumper/Exposer.php +++ b/src/Tracy/Dumper/Exposer.php @@ -239,7 +239,7 @@ public static function exposeDsCollection( Describer $describer, ): void { - foreach ($obj as $k => $v) { + foreach (clone $obj as $k => $v) { $describer->addPropertyTo($value, (string) $k, $v); } } diff --git a/tests/Tracy/Dumper.toText().specials.ds.phpt b/tests/Tracy/Dumper.toText().specials.ds.phpt index b2460650b..b475df4eb 100644 --- a/tests/Tracy/Dumper.toText().specials.ds.phpt +++ b/tests/Tracy/Dumper.toText().specials.ds.phpt @@ -34,3 +34,25 @@ Assert::match( XX, Dumper::toText($map), ); + + +$queue = new Ds\Queue(['value']); +Assert::match( + <<<'XX' + Ds\Queue #%d% + 0: 'value' + XX, + Dumper::toText($queue), +); +Assert::count(1, $queue); + + +$stack = new Ds\Stack(['value']); +Assert::match( + <<<'XX' + Ds\Stack #%d% + 0: 'value' + XX, + Dumper::toText($stack), +); +Assert::count(1, $stack);