mirror of
https://github.com/php/php-src.git
synced 2025-01-05 18:33:56 +08:00
f53225a99e
* Trying to resume a generator while it is already running now throws a fatal error. * Trying to use yield in finally while the generator is being force-closed (by GC) throws a fatal error. * Rewinding after the first yield now throws an Exception
30 lines
470 B
PHP
30 lines
470 B
PHP
--TEST--
|
|
yield can be used in finally (apart from forced closes)
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen() {
|
|
try {
|
|
echo "before return\n";
|
|
return;
|
|
echo "after return\n";
|
|
} finally {
|
|
echo "before yield\n";
|
|
yield "yielded value";
|
|
echo "after yield\n";
|
|
}
|
|
|
|
echo "after finally\n";
|
|
}
|
|
|
|
$gen = gen();
|
|
var_dump($gen->current());
|
|
$gen->next();
|
|
|
|
?>
|
|
--EXPECTF--
|
|
before return
|
|
before yield
|
|
string(%d) "yielded value"
|
|
after yield
|