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