1--TEST--
2Test with optimization of function calls
3--INI--
4opcache.enable=1
5opcache.enable_cli=1
6opcache.optimization_level=-1
7--SKIPIF--
8<?php require_once('skipif.inc'); ?>
9--FILE--
10<?php
11
12class A {
13	public $obj;
14	public function test($a) {
15	}
16}
17
18function a(&$b) {
19	$b = "changed";
20	return "done";
21}
22
23$a = "a";
24$b = "b";
25$c = "c";
26$f = "a";
27
28/*
29 * INIT_FCALL_BY_NAME
30 * SEND_VAR
31 * DO_FCALL
32 * DO_FCALL_BY_NAME
33 */
34foo(a($a));
35var_dump($a);
36$a = "a";
37
38/*
39 * INIT_FCALL_BY_NAME
40 *   INIT_FCALL_BY_NAME -- un-optimizable
41 *   DO_FCALL_BY_NAME   -- un-optimizable
42 * DO_FCALL_BY_NAME
43 */
44foo($f($a));
45var_dump($a);
46
47/*
48 * INIT_FCALL_BY_NAME
49 *   ZEND_NEW
50 *   DO_FCALL_BY_NAME
51 * DO_FCALL_BY_NAME
52 */
53foo(new A());
54
55/*
56 * INIT_FCALL_BY_NAME
57 * FETCH_OBJ_FUNC_ARG
58 * ZEND_SEND_VAR
59 * DO_FCALL_BY_NAME
60 */
61foo((new A)->obj);
62$obj = new A;
63ref($obj->obj);
64var_dump($obj->obj);
65
66ref(retarray()[0]);
67
68$a = "a";
69foo(a($a), $a, ref($b, $c), $obj);
70var_dump($a);
71var_dump($b);
72
73/*
74 * INIT_FCALL_BY_NAME
75 * SEND_VAL
76 * DO_FCALL_BY_NAME
77 */
78ref("xxx");
79
80function retarray() {
81	return array("retarray");
82}
83
84function foo($a) {
85	print_r(func_get_args());
86}
87
88function ref(&$b) {
89	$b = "changed";
90	return "ref";
91}
92--EXPECTF--
93Array
94(
95    [0] => done
96)
97string(7) "changed"
98Array
99(
100    [0] => done
101)
102string(7) "changed"
103Array
104(
105    [0] => A Object
106        (
107            [obj] =>
108        )
109
110)
111Array
112(
113    [0] =>
114)
115string(7) "changed"
116Array
117(
118    [0] => done
119    [1] => changed
120    [2] => ref
121    [3] => A Object
122        (
123            [obj] => changed
124        )
125
126)
127string(7) "changed"
128string(7) "changed"
129
130Fatal error: Uncaught Error: Cannot pass parameter 1 by reference in %soptimize_func_calls.php:%d
131Stack trace:
132#0 {main}
133  thrown in %soptimize_func_calls.php on line %d
134