mirror of
https://github.com/php/php-src.git
synced 2024-10-01 06:46:08 +00:00
be7b0bc3ec
Generator::throw($exception) throws an exception into the generator. The exception is thrown at the current point of suspension within the generator. It basically behaves as if the current yield statement were replaced with a throw statement and the generator subsequently resumed.
24 lines
360 B
PHP
24 lines
360 B
PHP
--TEST--
|
|
Generator::throw() on an already closed generator
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen() {
|
|
yield;
|
|
}
|
|
|
|
$gen = gen();
|
|
$gen->next();
|
|
$gen->next();
|
|
var_dump($gen->valid());
|
|
$gen->throw(new Exception('test'));
|
|
|
|
?>
|
|
--EXPECTF--
|
|
bool(false)
|
|
|
|
Fatal error: Uncaught exception 'Exception' with message 'test' in %s:%d
|
|
Stack trace:
|
|
#0 {main}
|
|
thrown in %s on line %d
|