summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob Weinand <bobwei9@hotmail.com>2015-08-20 23:24:28 +0200
committerBob Weinand <bobwei9@hotmail.com>2015-08-20 23:24:28 +0200
commit5ece3ec71c3eb8d3b706c68b82a8f7c4a14491c6 (patch)
treee62a527c40de92c23878223f454f1c6b345369ad
parent29a8981c81a7403070305ab4631c2fa9e858a082 (diff)
downloadphp-git-5ece3ec71c3eb8d3b706c68b82a8f7c4a14491c6.tar.gz
Fix bogus traces with ReflectionGenerator::getTrace()
-rw-r--r--NEWS3
-rw-r--r--Zend/zend_generators.c2
-rw-r--r--ext/reflection/tests/ReflectionGenerator_basic.phpt6
-rw-r--r--ext/reflection/tests/ReflectionGenerator_getTrace.phpt53
-rw-r--r--ext/reflection/tests/ReflectionGenerator_in_Generator.phpt6
5 files changed, 67 insertions, 3 deletions
diff --git a/NEWS b/NEWS
index c82c9358d0..f92f2838e2 100644
--- a/NEWS
+++ b/NEWS
@@ -17,6 +17,9 @@ PHP NEWS
- Standard:
. Fixed bug #70295 (Segmentation fault with setrawcookie). (Bob)
+- Reflection:
+ . Fixed bug causing bogus traces for ReflectionGenerator::getTrace(). (Bob)
+
20 Aug 2015, PHP 7.0.0 RC 1
- Core:
diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
index 0b54292159..18c6087382 100644
--- a/Zend/zend_generators.c
+++ b/Zend/zend_generators.c
@@ -273,7 +273,7 @@ static ZEND_COLD zend_function *zend_generator_get_constructor(zend_object *obje
ZEND_API zend_execute_data *zend_generator_check_placeholder_frame(zend_execute_data *ptr)
{
- if (!ptr->func && ptr->prev_execute_data && Z_OBJ(ptr->This)) {
+ if (!ptr->func && Z_OBJ(ptr->This)) {
if (Z_OBJCE(ptr->This) == zend_ce_generator) {
zend_generator *generator = (zend_generator *) Z_OBJ(ptr->This);
zend_generator *root = (generator->node.children < 1 ? generator : generator->node.ptr.leaf)->node.ptr.root;
diff --git a/ext/reflection/tests/ReflectionGenerator_basic.phpt b/ext/reflection/tests/ReflectionGenerator_basic.phpt
index 528d2d9ca2..6f35b6c244 100644
--- a/ext/reflection/tests/ReflectionGenerator_basic.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_basic.phpt
@@ -39,7 +39,11 @@ object(Generator)#2 (0) {
}
array(1) {
[0]=>
- array(2) {
+ array(4) {
+ ["file"]=>
+ string(%d) "%s"
+ ["line"]=>
+ int(%d)
["function"]=>
string(3) "foo"
["args"]=>
diff --git a/ext/reflection/tests/ReflectionGenerator_getTrace.phpt b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt
new file mode 100644
index 0000000000..05a46009e8
--- /dev/null
+++ b/ext/reflection/tests/ReflectionGenerator_getTrace.phpt
@@ -0,0 +1,53 @@
+--TEST--
+ReflectionGenerator::getTrace() over multiple Generators
+--FILE--
+<?php
+
+function foo() {
+ yield 1;
+ yield 2;
+}
+
+function bar()
+{
+ yield from foo();
+}
+
+function baz()
+{
+ yield from bar();
+}
+
+$gen = baz();
+$gen->valid();
+
+var_dump((new ReflectionGenerator($gen))->getTrace());
+
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ array(4) {
+ ["file"]=>
+ string(%d) "%s"
+ ["line"]=>
+ int(%d)
+ ["function"]=>
+ string(3) "foo"
+ ["args"]=>
+ array(0) {
+ }
+ }
+ [1]=>
+ array(4) {
+ ["file"]=>
+ string(%d) "%s"
+ ["line"]=>
+ int(%d)
+ ["function"]=>
+ string(3) "bar"
+ ["args"]=>
+ array(0) {
+ }
+ }
+}
diff --git a/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt b/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
index 9c0098d506..a227e1a213 100644
--- a/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
+++ b/ext/reflection/tests/ReflectionGenerator_in_Generator.phpt
@@ -46,7 +46,11 @@ object(ReflectionFunction)#4 (1) {
NULL
array(1) {
[0]=>
- array(2) {
+ array(4) {
+ ["file"]=>
+ string(%d) "%s"
+ ["line"]=>
+ int(%d)
["function"]=>
string(9) "{closure}"
["args"]=>