ReflectionGenerator now sends ReflectionException as expected

This commit is contained in:
Julien Pauli 2017-02-07 17:47:08 +01:00
parent a7269c09d2
commit ed4216c955
3 changed files with 44 additions and 2 deletions

View File

@ -2113,7 +2113,7 @@ ZEND_METHOD(reflection_generator, __construct)
ex = ((zend_generator *) Z_OBJ_P(generator))->execute_data;
if (!ex) {
zend_throw_exception(NULL, "Cannot create ReflectionGenerator based on a terminated Generator", 0);
_DO_THROW("Cannot create ReflectionGenerator based on a terminated Generator");
return;
}
@ -2125,7 +2125,7 @@ ZEND_METHOD(reflection_generator, __construct)
#define REFLECTION_CHECK_VALID_GENERATOR(ex) \
if (!ex) { \
zend_throw_exception(NULL, "Cannot fetch information from a terminated Generator", 0); \
_DO_THROW("Cannot fetch information from a terminated Generator"); \
return; \
}

View File

@ -0,0 +1,22 @@
--TEST--
ReflectionGenerator::getTrace()
--FILE--
<?php
function foo()
{
yield 1;
}
$g = foo();
$r = new ReflectionGenerator($g);
$g->next();
try {
$r->getTrace();
} catch (ReflectionException $e) {
echo $e->getMessage();
}
?>
--EXPECTF--
Cannot fetch information from a terminated Generator

View File

@ -0,0 +1,20 @@
--TEST--
ReflectionGenerator::__construct()
--FILE--
<?php
function foo()
{
yield 1;
}
$g = foo();
$g->next();
try {
$r = new ReflectionGenerator($g);
} catch (ReflectionException $e) {
echo "Done!\n";
}
?>
--EXPECTF--
Done!