--TEST-- Lazy objects: unset of magic property may not initialize object if method does not observe object state --FILE-- b = 2; } public function __unset($name) { } } function test(string $name, object $obj) { printf("# %s:\n", $name); var_dump($obj); unset($obj->a); var_dump($obj); } $reflector = new ReflectionClass(C::class); $obj = $reflector->newLazyGhost(function ($obj) { var_dump("initializer"); $obj->__construct(1); }); test('Ghost', $obj); $obj = $reflector->newLazyProxy(function ($obj) { var_dump("initializer"); return new C(1); }); test('Proxy', $obj); --EXPECTF-- # Ghost: lazy ghost object(C)#%d (0) { ["b"]=> uninitialized(int) } lazy ghost object(C)#%d (0) { ["b"]=> uninitialized(int) } # Proxy: lazy proxy object(C)#%d (0) { ["b"]=> uninitialized(int) } lazy proxy object(C)#%d (0) { ["b"]=> uninitialized(int) }