Fix bogus traces with ReflectionGenerator::getTrace()

This commit is contained in:
Bob Weinand 2015-08-20 23:24:28 +02:00
parent 29a8981c81
commit 5ece3ec71c
5 changed files with 67 additions and 3 deletions

3
NEWS
View File

@ -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:

View File

@ -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;

View File

@ -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"]=>

View File

@ -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) {
}
}
}

View File

@ -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"]=>