1--TEST-- 2Lazy Objects: array_walk() 3--FILE-- 4<?php 5 6class C { 7 public int $a = 1; 8} 9 10 11$reflector = new ReflectionClass(C::class); 12$obj = $reflector->newLazyProxy(function () { 13 return new C(); 14}); 15 16array_walk($obj, function (&$value, $key) { 17 try { 18 $value = 'string'; 19 } catch (Error $e) { 20 printf("%s: %s\n", $e::class, $e->getMessage()); 21 } 22 $value = 2; 23}); 24 25var_dump($obj); 26 27?> 28--EXPECTF-- 29TypeError: Cannot assign string to reference held by property C::$a of type int 30lazy proxy object(C)#%d (1) { 31 ["instance"]=> 32 object(C)#%d (1) { 33 ["a"]=> 34 int(2) 35 } 36} 37