]> granicus.if.org Git - php/commitdiff
ReflectionGenerator now sends ReflectionException as expected
authorJulien Pauli <jpauli@php.net>
Tue, 7 Feb 2017 16:47:08 +0000 (17:47 +0100)
committerJulien Pauli <jpauli@php.net>
Tue, 7 Feb 2017 16:47:08 +0000 (17:47 +0100)
ext/reflection/php_reflection.c
ext/reflection/tests/027.phpt [new file with mode: 0644]
ext/reflection/tests/028.phpt [new file with mode: 0644]

index b7c793c4b1a44d74d28fb6b2610d228bfd46853d..b9ae4d1c85c4d737d96ab692a04a8dceaa6c7849 100644 (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; \
        }
 
diff --git a/ext/reflection/tests/027.phpt b/ext/reflection/tests/027.phpt
new file mode 100644 (file)
index 0000000..06db60b
--- /dev/null
@@ -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 (file)
index 0000000..5f1e7a2
--- /dev/null
@@ -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!