mirror of
https://github.com/php/php-src.git
synced 2024-09-22 02:17:32 +00:00
ReflectionGenerator now sends ReflectionException as expected
This commit is contained in:
parent
a7269c09d2
commit
ed4216c955
@ -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; \
|
||||
}
|
||||
|
||||
|
22
ext/reflection/tests/027.phpt
Normal file
22
ext/reflection/tests/027.phpt
Normal 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
|
20
ext/reflection/tests/028.phpt
Normal file
20
ext/reflection/tests/028.phpt
Normal 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!
|
Loading…
Reference in New Issue
Block a user