Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/Tracy/Dumper/Exposer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
47 changes: 47 additions & 0 deletions tests/Dumper/Dumper.toText().specials.lazyObject.virtual.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php declare(strict_types=1);

/**
* Test: Tracy\Dumper::toText() & lazy object with virtual properties
* @phpversion 8.4
*/

use Tester\Assert;
use Tracy\Dumper;

require __DIR__ . '/../bootstrap.php';


class LazyClassWithVirtualProp
{
public function __construct(
public int $id,
public string $title,
) {
}

public string $virtual {
get => $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]),
);