mirror of
https://github.com/php/php-src.git
synced 2025-08-18 06:58:55 +02:00

This implements a reduced variant of #1226 with just the following change: -Fatal error: Uncaught exception 'EngineException' with message 'Call to private method foo::bar() from context ''' in %s:%d +Fatal error: Uncaught EngineException: Call to private method foo::bar() from context '' in %s:%d The '' wrapper around messages is very weird if the exception message itself contains ''. Futhermore having the message wrapped in '' doesn't work for the "and defined" suffix of TypeExceptions.
50 lines
951 B
PHP
50 lines
951 B
PHP
--TEST--
|
|
Multiple yield from on a same Generator throwing an Exception
|
|
--FILE--
|
|
<?php
|
|
function from() {
|
|
yield 1;
|
|
throw new Exception();
|
|
}
|
|
|
|
function gen($gen) {
|
|
try {
|
|
var_dump(yield from $gen);
|
|
} catch (Exception $e) { print "Caught exception!\n$e\n"; }
|
|
}
|
|
|
|
$gen = from();
|
|
$gens[] = gen($gen);
|
|
$gens[] = gen($gen);
|
|
|
|
foreach ($gens as $g) {
|
|
$g->current(); // init.
|
|
}
|
|
|
|
do {
|
|
foreach ($gens as $i => $g) {
|
|
print "Generator $i\n";
|
|
var_dump($g->current());
|
|
$g->next();
|
|
}
|
|
} while($gens[0]->valid());
|
|
?>
|
|
--EXPECTF--
|
|
Generator 0
|
|
int(1)
|
|
Caught exception!
|
|
Exception in %s:%d
|
|
Stack trace:
|
|
#0 %s(%d): from()
|
|
#1 [internal function]: gen(Object(Generator))
|
|
#2 %s(%d): Generator->next()
|
|
#3 {main}
|
|
Generator 1
|
|
|
|
Fatal error: Uncaught ClosedGeneratorException: Generator yielded from aborted, no return value available in %s:%d
|
|
Stack trace:
|
|
#0 [internal function]: gen(Object(Generator))
|
|
#1 %s(%d): Generator->current()
|
|
#2 {main}
|
|
thrown in %s on line %d
|
|
|