1--TEST--
2Observer: Retvals are observable that are: refcounted, IS_VAR
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_return_value=1
10--FILE--
11<?php
12class MyRetval {}
13
14function getObj() {
15    return new MyRetval(); // Refcounted
16}
17
18function foo() {
19    return getObj(); // IS_VAR
20}
21
22$res = foo(); // Retval used
23foo(); // Retval unused
24
25function bar($what) {
26  return 'This gets ' . $what . ' in the return handler when unused'; // Refcounted + IS_VAR
27}
28
29$res = bar('freed'); // Retval used
30bar('freed'); // Retval unused
31
32echo 'Done' . PHP_EOL;
33?>
34--EXPECTF--
35<!-- init '%s%eobserver_retval_%d.php' -->
36<file '%s%eobserver_retval_%d.php'>
37  <!-- init foo() -->
38  <foo>
39    <!-- init getObj() -->
40    <getObj>
41    </getObj:object(MyRetval)#%d>
42  </foo:object(MyRetval)#%d>
43  <foo>
44    <getObj>
45    </getObj:object(MyRetval)#%d>
46  </foo:object(MyRetval)#%d>
47  <!-- init bar() -->
48  <bar>
49  </bar:'This gets freed in the return handler when unused'>
50  <bar>
51  </bar:'This gets freed in the return handler when unused'>
52Done
53</file '%s%eobserver_retval_%d.php'>
54