diff --git a/src/Tracy/Dumper/Exposer.php b/src/Tracy/Dumper/Exposer.php index eb14a504a..99f75e07c 100644 --- a/src/Tracy/Dumper/Exposer.php +++ b/src/Tracy/Dumper/Exposer.php @@ -20,6 +20,16 @@ final class Exposer { public static function exposeObject(object $obj, Value $value, Describer $describer): void { + if (PHP_VERSION_ID >= 80400 && ($rc = new \ReflectionClass($obj))->isUninitializedLazyObject($obj)) { + //$describer->addPropertyTo($value, 'lazy-object', '', Value::PropertyVirtual); + $value->value .= ' (lazy)'; + if ($init = $rc->getLazyInitializer($obj)) { + $describer->addPropertyTo($value, 'initializer', $init, Value::PropertyVirtual); + $value->items[0][1]->collapsed = false; + } + return; + } + $values = get_mangled_object_vars($obj); $props = self::getProperties($obj::class); diff --git a/tests/Tracy/Dumper.toText().specials.lazy.phpt b/tests/Tracy/Dumper.toText().specials.lazy.phpt new file mode 100644 index 000000000..b78774b5c --- /dev/null +++ b/tests/Tracy/Dumper.toText().specials.lazy.phpt @@ -0,0 +1,33 @@ +newLazyGhost(function (MyClass $ghost) {}); + + +Assert::match( + <<<'XX' + array (1) + 0 => MyClass (lazy) #%d% + | initializer: Closure($ghost) #%d% + XX, + Dumper::toText([$ghost], [Dumper::DEPTH => 3]), +); +