<?php class It implements \IteratorAggregate { public $gen; public function getIterator(): \Generator { yield 'foo'; $this->gen->throw(new Exception()); var_dump("not executed"); } public function __destruct() { var_dump(__METHOD__); } } function f($it) { try { var_dump(new stdClass, yield from $it); } finally { var_dump(__FUNCTION__); } } $it = new It(); $gen = f($it); $it->gen = $gen; var_dump($gen->current()); $gen->next(); gc_collect_cycles(); ?>
You have javascript disabled. You will not be able to edit any code.