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