mirror of
https://github.com/php/php-src.git
synced 2024-11-24 02:15:04 +08:00
75a678a7e3
Co-authored-by: Nikita Popov <nikita.ppv@gmail.com>
31 lines
592 B
PHP
31 lines
592 B
PHP
--TEST--
|
|
Exception from valid() during yield from
|
|
--FILE--
|
|
<?php
|
|
|
|
class FooBar implements Iterator {
|
|
function rewind(): void {}
|
|
function current(): mixed {}
|
|
function key(): mixed {}
|
|
function next(): void {}
|
|
function valid(): bool {
|
|
throw new Exception("Exception from valid()");
|
|
}
|
|
}
|
|
|
|
function gen() {
|
|
try {
|
|
// the fact that the yield from result is used is relevant.
|
|
var_dump(yield from new FooBar);
|
|
} catch (Exception $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
}
|
|
|
|
$x = gen();
|
|
$x->current();
|
|
|
|
?>
|
|
--EXPECT--
|
|
Exception from valid()
|