Create a ghost proxy with ProxyManager

Code
<?php

use ProxyManager\Factory\LazyLoadingGhostFactory;

class Foo
{
    private $foo;
    
    public function __construct()
    {
        echo __METHOD__;
    }
    
    public function setFoo($foo)
    {
        $this->foo = $foo;
    }
    
    public function getFoo()
    {
        return $this->foo;
    }
}

$factory = new LazyLoadingGhostFactory();

$proxy = $factory->createProxy(
    Foo::CLASS,
    function ($proxy, $method, $parameters, &$initializer) {
        // no further instantiation
        $initializer = null;
        $proxy->setFoo('foo');
    }
);

echo $proxy->getFoo();
Result
foo
Used Versions
PHP 8.3, Laminas MVC 3.2, Symfony 5.2, Laravel 8.28, PHPUnit 9.5, Doctrine ORM 2.8