--TEST-- Lazy objects: GC 002 --FILE-- newInstanceWithoutConstructor(); (new ReflectionClass($obj))->resetAsLazyGhost($obj, function () use ($canary) { }); $canary->value = $obj; $canary = null; $obj = null; gc_collect_cycles(); } function proxy() { printf("# Proxy:\n"); $canary = new Canary(); $obj = (new ReflectionClass(C::class))->newInstanceWithoutConstructor(); (new ReflectionClass($obj))->resetAsLazyProxy($obj, function () use ($canary) { return new C(); }); $canary->value = $obj; $canary = null; $obj = null; gc_collect_cycles(); } ghost(); proxy(); ?> ==DONE== --EXPECT-- # Ghost: string(10) "__destruct" # Proxy: string(10) "__destruct" ==DONE==