Create a lazy loading proxy without an extra class with ProxyManager

Code
<?php

use ProxyManager\Factory\LazyLoadingValueHolderFactory;

// a class which does a lot of expensive thing
class Foo
{
    public function 
__construct()
    {
        echo 
'<b>Foo constructor called</b>' PHP_EOL;
    }
    
    public function 
getValue()
    {
        return 
'Value of Foo' PHP_EOL;
    }
}

$factory = new LazyLoadingValueHolderFactory();

echo 
'create lazy proxy of Foo class' PHP_EOL;
$lazyproxy $factory->createProxy(Foo::CLASS,
    function (&
$wrappedObject$proxy$method$params, &$initializer) {
        
$wrappedObject = new Foo();
        
// don't initialize class again. Use same object
        
$initializer null;
    
        return 
true;
    }
);
echo 
'Foo proxy created' PHP_EOL;

echo 
$lazyproxy->getValue();
Result
create lazy proxy of Foo class
Foo proxy created
Foo constructor called
Value of Foo
Used Versions
PHP 7.1, Zend 3.0, Symfony 3.2, Laravel 5.2, PHPUnit 5.6, Doctrine 2.6