From: Julien Pauli Date: Tue, 7 Feb 2017 16:47:08 +0000 (+0100) Subject: ReflectionGenerator now sends ReflectionException as expected X-Git-Tag: php-7.2.0alpha1~394 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ed4216c955516a48285e22eb999c0a641d4a1d63;p=php ReflectionGenerator now sends ReflectionException as expected --- diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c index b7c793c4b1..b9ae4d1c85 100644 --- a/ext/reflection/php_reflection.c +++ b/ext/reflection/php_reflection.c @@ -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; \ } diff --git a/ext/reflection/tests/027.phpt b/ext/reflection/tests/027.phpt new file mode 100644 index 0000000000..06db60b8ec --- /dev/null +++ b/ext/reflection/tests/027.phpt @@ -0,0 +1,22 @@ +--TEST-- +ReflectionGenerator::getTrace() +--FILE-- +next(); + +try { + $r->getTrace(); +} catch (ReflectionException $e) { + echo $e->getMessage(); +} +?> +--EXPECTF-- +Cannot fetch information from a terminated Generator diff --git a/ext/reflection/tests/028.phpt b/ext/reflection/tests/028.phpt new file mode 100644 index 0000000000..5f1e7a2faa --- /dev/null +++ b/ext/reflection/tests/028.phpt @@ -0,0 +1,20 @@ +--TEST-- +ReflectionGenerator::__construct() +--FILE-- +next(); + +try { + $r = new ReflectionGenerator($g); +} catch (ReflectionException $e) { + echo "Done!\n"; +} +?> +--EXPECTF-- +Done!