1--TEST-- 2Lazy objects: Object with no props is never lazy 3--FILE-- 4<?php 5 6class C {} 7 8#[AllowDynamicProperties] 9class D {} 10 11function test(string $name, object $obj, object $obj2, object $obj3) { 12 printf("# %s:\n", $name); 13 14 var_dump((new ReflectionClass($obj::class))->isUninitializedLazyObject($obj)); 15 var_dump($obj); 16 17 var_dump((new ReflectionClass($obj2::class))->isUninitializedLazyObject($obj2)); 18 var_dump($obj2); 19 20 var_dump((new ReflectionClass($obj3::class))->isUninitializedLazyObject($obj3)); 21 var_dump($obj3); 22} 23 24$obj = new C(); 25(new ReflectionClass($obj))->resetAsLazyGhost($obj, function ($obj) { 26 var_dump("initializer"); 27}); 28 29$obj2 = new D(); 30$obj2->dynamic = 'value'; 31(new ReflectionClass($obj2))->resetAsLazyGhost($obj2, function ($obj2) { 32 var_dump("initializer"); 33}); 34 35$obj3 = (new ReflectionClass(C::class))->newLazyGhost(function () { 36 var_dump("initializer"); 37}); 38 39test('Ghost', $obj, $obj2, $obj3); 40 41$obj = new C(); 42(new ReflectionClass($obj))->resetAsLazyProxy($obj, function ($obj) { 43 var_dump("initializer"); 44}); 45 46$obj2 = new D(); 47$obj2->dynamic = 'value'; 48(new ReflectionClass($obj2))->resetAsLazyProxy($obj2, function ($obj2) { 49 var_dump("initializer"); 50}); 51 52$obj3 = (new ReflectionClass(C::class))->newLazyGhost(function () { 53 var_dump("initializer"); 54}); 55 56test('Proxy', $obj, $obj2, $obj3); 57 58--EXPECTF-- 59# Ghost: 60bool(false) 61object(C)#%d (0) { 62} 63bool(false) 64object(D)#%d (0) { 65} 66bool(false) 67object(C)#%d (0) { 68} 69# Proxy: 70bool(false) 71object(C)#%d (0) { 72} 73bool(false) 74object(D)#%d (0) { 75} 76bool(false) 77object(C)#%d (0) { 78} 79