1--TEST-- 2Lazy objects: resetAsLazy*() on already lazy object is not allowed 3--FILE-- 4<?php 5 6class C extends stdClass { 7 public int $a; 8} 9 10$reflector = new ReflectionClass(C::class); 11 12printf("# Ghost:\n"); 13 14$obj = new C(); 15$reflector->resetAsLazyGhost($obj, function () {}); 16 17try { 18 $reflector->resetAsLazyGhost($obj, function ($obj) { 19 }); 20} catch (\Exception $e) { 21 printf("%s: %s\n", $e::class, $e->getMessage()); 22} 23 24printf("# Proxy:\n"); 25 26$obj = new C(); 27$reflector->resetAsLazyProxy($obj, function () {}); 28 29try { 30 $reflector->resetAsLazyProxy($obj, function ($obj) { 31 }); 32} catch (\Exception $e) { 33 printf("%s: %s\n", $e::class, $e->getMessage()); 34} 35 36$obj = new C(); 37$reflector->resetAsLazyProxy($obj, function () { 38 return new C(); 39}); 40$reflector->initializeLazyObject($obj); 41 42try { 43 $reflector->resetAsLazyProxy($obj, function ($obj) { 44 }); 45} catch (\Exception $e) { 46 printf("%s: %s\n", $e::class, $e->getMessage()); 47} 48 49?> 50==DONE== 51--EXPECT-- 52# Ghost: 53ReflectionException: Object is already lazy 54# Proxy: 55ReflectionException: Object is already lazy 56==DONE== 57