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