View Issue Details

IDProjectCategoryView StatusLast Update
0002376XdebugUncategorizedpublic2025-11-06 16:23
ReporterHypeMC Assigned To 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Summary0002376: Variables not shown when lazy objects are used
Description

Product version is 3.4.7-dev, but it's not in the select menu.

When using PHP's lazy objects, the variable list in the PHPStorm debugger occasionally appears empty.
This happens before the lazy object is initialized.

Here's a simple example:

class Example
{
    public function __construct(public int $prop)
    {
        echo __METHOD__, "\n";
    }
}

(function () {
    $reflector = new ReflectionClass(Example::class);

    $lazyObject = $reflector->newLazyGhost(function (Example $object) {
        // Initialize object in-place
        $object->__construct(1);
    });

    var_dump($lazyObject);

    var_dump($lazyObject->prop);
})();
Steps To Reproduce
  1. Set a breakpoint before the lazy object is initialized (e.g. at the first var_dump() call).
  2. Start debugging.
  3. Observe that the variable list in PHPStorm is empty (see image 1).
  4. Continue execution until the object is initialized.
  5. After initialization, both $reflector and $lazyObject appear correctly in the debugger (see image 2).
TagsNo tags attached.
Operating SystemUbuntu 22.04
PHP Version8.4.10-8.4.19

Activities

derick

2025-11-06 16:23

administrator   ~0007396

Like 0002377, this also seems to be a PhpStorm issue. It works fine with VS Code, and with PhpStorm, Xdebug does send the variables over when it's at that first var_dump():

[2266130] [Step Debug] -> <response xmlns="urn:debugger_protocol_v1" xmlns:xdebug="https://xdebug.org/dbgp/xdebug" command="context_get" transaction_id="23" context="0"><property name="$lazyObject" fullname="$lazyObject" type="object" facet="lazy-ghost"></property><property name="$reflector" fullname="$reflector" type="object" classname="ReflectionClass" children="1" numchildren="1" page="0" pagesize="100"><property name="name" fullname="$reflector-&gt;name" facet="public" type="string" size="7" encoding="base64"><![CDATA[RXhhbXBsZQ==]]></property></property></response>