xref: /PHP-8.2/ext/zend_test/tests/gh16514.phpt (revision c5c4c3be)
1--TEST--
2GH-16514: Nested generator in zend_test observer
3--EXTENSIONS--
4zend_test
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.show_output=1
8zend_test.observer.show_init_backtrace=1
9--FILE--
10<?php
11
12class Foo {
13    public function __destruct() {
14        debug_print_backtrace();
15    }
16}
17function bar() {
18    yield from foo();
19}
20function foo() {
21    $foo = new Foo();
22    yield;
23}
24$gen = bar();
25foreach ($gen as $dummy);
26
27?>
28--EXPECTF--
29<!-- init '%sgh16514.php' -->
30<!--
31    {main} %sgh16514.php
32-->
33<!-- init bar() -->
34<!--
35    bar()
36    {main} %sgh16514.php
37-->
38<!-- init foo() -->
39<!--
40    foo()
41    bar()
42    {main} %sgh16514.php
43-->
44<!-- init Foo::__destruct() -->
45<!--
46    Foo::__destruct()
47    bar()
48    {main} %sgh16514.php
49-->
50<!-- init debug_print_backtrace() -->
51<!--
52    debug_print_backtrace()
53    Foo::__destruct()
54    bar()
55    {main} %sgh16514.php
56-->
57#0 %s(%d): Foo->__destruct()
58#1 %s(%d): bar()
59