1--TEST-- 2Lazy objects: skipLazyInitialization() can not be used on dynamic properties 3--FILE-- 4<?php 5 6#[AllowDynamicProperties] 7class C { 8 public $a = 1; 9} 10 11function test(string $name, object $obj) { 12 printf("# %s\n", $name); 13 14 $c = new C(); 15 $c->dyn = 1; 16 $propReflector = new ReflectionProperty($c, 'dyn'); 17 18 try { 19 $propReflector->skipLazyInitialization($obj); 20 } catch (\ReflectionException $e) { 21 printf("%s: %s\n", $e::class, $e->getMessage()); 22 } 23} 24 25$reflector = new ReflectionClass(C::class); 26$obj = $reflector->newLazyGhost(function () { 27 throw new \Exception('initializer'); 28}); 29 30test('Ghost', $obj); 31 32$obj = $reflector->newLazyProxy(function () { 33 throw new \Exception('initializer'); 34}); 35 36test('Proxy', $obj); 37 38?> 39--EXPECT-- 40# Ghost 41ReflectionException: Can not use skipLazyInitialization on dynamic property C::$dyn 42# Proxy 43ReflectionException: Can not use skipLazyInitialization on dynamic property C::$dyn 44