<?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();