1--TEST--
2Observer: Show backtrace on init
3--EXTENSIONS--
4zend_test
5--INI--
6zend_test.observer.enabled=1
7zend_test.observer.show_output=1
8zend_test.observer.observe_all=1
9zend_test.observer.show_init_backtrace=1
10--FILE--
11<?php
12class TestClass
13{
14    private function bar($number)
15    {
16        return $number + 2;
17    }
18
19    public function foo()
20    {
21        return array_map(function ($value) {
22            return $this->bar($value);
23        }, [40, 1335]);
24    }
25}
26
27function gen()
28{
29    $test = new TestClass();
30    yield $test->foo();
31}
32
33function foo()
34{
35    return gen()->current();
36}
37
38var_dump(foo());
39?>
40--EXPECTF--
41<!-- init '%s%eobserver_backtrace_%d.php' -->
42<!--
43    {main} %s%eobserver_backtrace_%d.php
44-->
45<file '%s%eobserver_backtrace_%d.php'>
46  <!-- init foo() -->
47  <!--
48      foo()
49      {main} %s%eobserver_backtrace_%d.php
50  -->
51  <foo>
52    <!-- init gen() -->
53    <!--
54        gen()
55        Generator::current()
56        foo()
57        {main} %s%eobserver_backtrace_%d.php
58    -->
59    <gen>
60      <!-- init TestClass::foo() -->
61      <!--
62          TestClass::foo()
63          gen()
64          Generator::current()
65          foo()
66          {main} %s%eobserver_backtrace_%d.php
67      -->
68      <TestClass::foo>
69        <!-- init TestClass::{closure}() -->
70        <!--
71            TestClass::{closure}()
72            array_map()
73            TestClass::foo()
74            gen()
75            Generator::current()
76            foo()
77            {main} %s%eobserver_backtrace_%d.php
78        -->
79        <TestClass::{closure}>
80          <!-- init TestClass::bar() -->
81          <!--
82              TestClass::bar()
83              TestClass::{closure}()
84              array_map()
85              TestClass::foo()
86              gen()
87              Generator::current()
88              foo()
89              {main} %s%eobserver_backtrace_%d.php
90          -->
91          <TestClass::bar>
92          </TestClass::bar>
93        </TestClass::{closure}>
94        <TestClass::{closure}>
95          <TestClass::bar>
96          </TestClass::bar>
97        </TestClass::{closure}>
98      </TestClass::foo>
99    </gen>
100  </foo>
101array(2) {
102  [0]=>
103  int(42)
104  [1]=>
105  int(1337)
106}
107</file '%s%eobserver_backtrace_%d.php'>
108