1--TEST-- 2Exception from valid() during yield from 3--FILE-- 4<?php 5 6class FooBar implements Iterator { 7 function rewind(): void {} 8 function current(): mixed {} 9 function key(): mixed {} 10 function next(): void {} 11 function valid(): bool { 12 throw new Exception("Exception from valid()"); 13 } 14} 15 16function gen() { 17 try { 18 // the fact that the yield from result is used is relevant. 19 var_dump(yield from new FooBar); 20 } catch (Exception $e) { 21 echo $e->getMessage(), "\n"; 22 } 23} 24 25$x = gen(); 26$x->current(); 27 28?> 29--EXPECT-- 30Exception from valid() 31