com php-src: ReflectionGenerator now sends ReflectionException as expected: ext/reflection/php_reflection.c ext/reflection/tests/0 27.phpt
ext/reflection/tests/028.phpt
| From: | JulienPauli | Date: | Tue, 07 Feb 2017 16:47:08 +0000 |
| Subject: | com php-src: ReflectionGenerator now sends ReflectionException as expected: ext/reflection/php_reflection.c ext/reflection/tests/0 27.phpt ext/reflection/tests/028.phpt |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-97036@lists.php.net to get a copy of this message | ||
Commit: ed4216c955516a48285e22eb999c0a641d4a1d63
Author: Julien Pauli <jpauli@php.net> Tue, 7 Feb 2017 17:47:08 +0100
Parents: a7269c09d23444d141d65d992605d952d70ae8b9
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=ed4216c955516a48285e22eb999c0a641d4a1d63
Log:
ReflectionGenerator now sends ReflectionException as expected
Changed paths:
M ext/reflection/php_reflection.c
A ext/reflection/tests/027.phpt
A ext/reflection/tests/028.phpt
Diff:
diff --git a/ext/reflection/php_reflection.c b/ext/reflection/php_reflection.c
index b7c793c..b9ae4d1 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 0000000..06db60b
--- /dev/null
+++ b/ext/reflection/tests/027.phpt
@@ -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
diff --git a/ext/reflection/tests/028.phpt b/ext/reflection/tests/028.phpt
new file mode 100644
index 0000000..5f1e7a2
--- /dev/null
+++ b/ext/reflection/tests/028.phpt
@@ -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!