1--TEST-- 2Lazy objects: setRawValueWithoutLazyInitialization() skips hooks 3--FILE-- 4<?php 5 6class C { 7 public $a { 8 set($value) { throw new \Exception('hook'); $this->a = $value; } 9 get { return $this->a; } 10 } 11 public $b; 12} 13 14function test(string $name, object $obj) { 15 printf("# %s\n", $name); 16 17 $reflector = new ReflectionClass(C::class); 18 $reflector->getProperty('a')->setRawValueWithoutLazyInitialization($obj, 'test'); 19 20 var_dump(!$reflector->isUninitializedLazyObject($obj)); 21 var_dump($obj); 22} 23 24$reflector = new ReflectionClass(C::class); 25$obj = $reflector->newLazyGhost(function () { 26 throw new \Exception('initializer'); 27}); 28 29test('Ghost', $obj); 30 31$obj = $reflector->newLazyProxy(function () { 32 throw new \Exception('initializer'); 33}); 34 35test('Proxy', $obj); 36 37?> 38--EXPECTF-- 39# Ghost 40bool(false) 41lazy ghost object(C)#%d (1) { 42 ["a"]=> 43 string(4) "test" 44} 45# Proxy 46bool(false) 47lazy proxy object(C)#%d (1) { 48 ["a"]=> 49 string(4) "test" 50} 51