1--TEST-- 2Lazy objects: sub-classes of stdClass can be initialized lazily 3--FILE-- 4<?php 5 6class C extends stdClass { 7} 8 9$reflector = new ReflectionClass(C::class); 10 11print "# Ghost:\n"; 12 13$obj = $reflector->newLazyGhost(function ($obj) { 14 var_dump("initializer"); 15 $obj->__construct(); 16}); 17var_dump($obj); 18 19print "# Proxy:\n"; 20 21$obj = $reflector->newLazyProxy(function ($obj) { 22 var_dump("initializer"); 23 $obj->__construct(); 24}); 25var_dump($obj); 26 27--EXPECTF-- 28# Ghost: 29object(C)#%d (0) { 30} 31# Proxy: 32object(C)#%d (0) { 33} 34