1--TEST-- 2Throwing into a generator yielding from an array/iterator 3--FILE-- 4<?php 5 6$data = [1, 2, 3]; 7 8function yielditer($arr) { 9 foreach($arr as $val) { 10 yield $val; 11 } 12} 13 14function yf($in) { 15 yield from $in; 16} 17 18function test($g) { 19 var_dump($g->current()); 20 try { 21 $g->throw(new Exception("Exception!")); 22 } catch (Exception $e) { 23 echo "{$e->getMessage()}\n"; 24 } 25 var_dump($g->current()); 26} 27 28$yfiter = yf($data); 29$yfgen = yf(yielditer($data)); 30 31test(yf($data)); 32echo "\n"; 33test(yf(yielditer($data))); 34 35?> 36--EXPECT-- 37int(1) 38Exception! 39NULL 40 41int(1) 42Exception! 43NULL 44