php-src/Zend/tests/foreach_empty_loop_leak.phpt
Máté Kocsis 75a678a7e3
Declare tentative return types for Zend (#7251)
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
2021-07-19 13:44:20 +02:00

24 lines
406 B
PHP

--TEST--
Empty foreach loops with exception must not leak
--FILE--
<?php
class Foo implements IteratorAggregate {
public function getIterator(): Traversable {
return new ArrayIterator([]);
}
public function __destruct() {
throw new Exception;
}
}
try {
foreach (new Foo as $x);
} catch (Exception $e) {
echo "Exception caught\n";
}
?>
--EXPECT--
Exception caught