1--TEST-- 2Typed property type coercion through ArrayIterator 3--FILE-- 4<?php 5class A implements IteratorAggregate { 6 function __construct( 7 public string $foo = 'bar' 8 ) {} 9 10 function getIterator(): Traversable { 11 return new ArrayIterator($this); 12 } 13} 14 15$obj = new A; 16foreach ($obj as $k => &$v) { 17 $v = 42; 18} 19 20var_dump($obj); 21?> 22--EXPECT-- 23object(A)#1 (1) { 24 ["foo"]=> 25 &string(2) "42" 26} 27