1--TEST-- 2Lazy objects: setRawValueWithoutLazyInitialization() sets value 3--FILE-- 4<?php 5 6class C { 7 public $a; 8 public $b; 9} 10 11function test(string $name, object $obj) { 12 printf("# %s\n", $name); 13 14 $reflector = new ReflectionClass(C::class); 15 $reflector->getProperty('a')->setRawValueWithoutLazyInitialization($obj, 'test'); 16 17 var_dump(!$reflector->isUninitializedLazyObject($obj)); 18 var_dump($obj); 19} 20 21$reflector = new ReflectionClass(C::class); 22$obj = $reflector->newLazyGhost(function () { 23 throw new \Exception('initializer'); 24}); 25 26test('Ghost', $obj); 27 28$obj = $reflector->newLazyProxy(function () { 29 throw new \Exception('initializer'); 30}); 31 32test('Proxy', $obj); 33 34?> 35--EXPECTF-- 36# Ghost 37bool(false) 38lazy ghost object(C)#%d (1) { 39 ["a"]=> 40 string(4) "test" 41} 42# Proxy 43bool(false) 44lazy proxy object(C)#%d (1) { 45 ["a"]=> 46 string(4) "test" 47} 48