mirror of
https://github.com/php/php-src.git
synced 2024-10-02 23:36:16 +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.
20 lines
375 B
PHP
20 lines
375 B
PHP
--TEST--
|
|
Generator::throw() where the exception is not caught in the generator
|
|
--FILE--
|
|
<?php
|
|
|
|
function gen() {
|
|
yield 'thisThrows';
|
|
yield 'notReached';
|
|
}
|
|
|
|
$gen = gen();
|
|
var_dump($gen->throw(new RuntimeException('test')));
|
|
|
|
?>
|
|
--EXPECTF--
|
|
Fatal error: Uncaught exception 'RuntimeException' with message 'test' in %s:%d
|
|
Stack trace:
|
|
#0 {main}
|
|
thrown in %s on line %d
|