diff --git a/src/Tracy/Dumper/Exposer.php b/src/Tracy/Dumper/Exposer.php index 35a0165d7..3f647cf5b 100644 --- a/src/Tracy/Dumper/Exposer.php +++ b/src/Tracy/Dumper/Exposer.php @@ -294,7 +294,7 @@ private static function exposeLazyObject(object $obj, Describer $describer, Valu { $rc = new \ReflectionClass($obj); foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC) as $prop) { - if (!$prop->isLazy($obj)) { + if (!$prop->isLazy($obj) && !$prop->isVirtual()) { $describer->addPropertyTo( $value, $prop->getName(), diff --git a/tests/Dumper/Dumper.toText().specials.lazyObject.virtual.phpt b/tests/Dumper/Dumper.toText().specials.lazyObject.virtual.phpt new file mode 100644 index 000000000..be024f6f5 --- /dev/null +++ b/tests/Dumper/Dumper.toText().specials.lazyObject.virtual.phpt @@ -0,0 +1,47 @@ + $this->title . '!'; + } +} + +$rc = new ReflectionClass(LazyClassWithVirtualProp::class); +$ghost = $rc->newLazyGhost(function () {}); + +// new ghost - virtual property should not appear (it has no backing value) +Assert::match( + <<<'XX' + LazyClassWithVirtualProp (lazy) #%d% + XX, + Dumper::toText($ghost, [Dumper::DEPTH => 3]), +); + +// preinitialized property - virtual property should still not appear +$rc->getProperty('id')->setRawValueWithoutLazyInitialization($ghost, 123); + +Assert::match( + <<<'XX' + LazyClassWithVirtualProp (lazy) #%d% + id: 123 + XX, + Dumper::toText($ghost, [Dumper::DEPTH => 3]), +);