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