1--TEST-- 2Lazy objects: clone is independent of the original object 3--FILE-- 4<?php 5 6class SomeObj { 7 public string $foo = 'A'; 8 public string $dummy; 9} 10 11$reflector = new ReflectionClass(SomeObj::class); 12 13$predefinedObject = new SomeObj(); 14$initializer = function () use ($predefinedObject) { 15 return $predefinedObject; 16}; 17 18$myProxy = $reflector->newLazyProxy($initializer); 19$reflector->getProperty('foo')->skipLazyInitialization($myProxy); 20 21$clonedProxy = clone $myProxy; 22var_dump($clonedProxy->foo); 23 24$reflector->initializeLazyObject($myProxy); 25$myProxy->foo = 'B'; 26 27$reflector->initializeLazyObject($clonedProxy); 28 29var_dump($myProxy->foo); 30var_dump($clonedProxy->foo); 31 32--EXPECT-- 33string(1) "A" 34string(1) "B" 35string(1) "A" 36