1--TEST-- 2Lazy objects: resetAsLazy*() can make a real instance lazy 3--FILE-- 4<?php 5 6class Obj { 7 public function __construct( 8 public string $name, 9 ) {} 10} 11 12$r = new ReflectionClass(Obj::class); 13 14$obj1 = new Obj('obj1'); 15$r->resetAsLazyProxy($obj1, function () use (&$obj2) { 16 $obj2 = new Obj('obj2'); 17 return $obj2; 18}); 19$r->initializeLazyObject($obj1); 20$r->resetAsLazyProxy($obj2, function () { 21 return new Obj('obj3'); 22}); 23var_dump($obj1->name); 24 25?> 26==DONE== 27--EXPECT-- 28string(4) "obj3" 29==DONE== 30