1--TEST-- 2Test with optimization of function calls 3--INI-- 4opcache.enable=1 5opcache.enable_cli=1 6opcache.optimization_level=-1 7--EXTENSIONS-- 8opcache 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?> 93--EXPECTF-- 94Array 95( 96 [0] => done 97) 98string(7) "changed" 99Array 100( 101 [0] => done 102) 103string(7) "changed" 104Array 105( 106 [0] => A Object 107 ( 108 [obj] => 109 ) 110 111) 112Array 113( 114 [0] => 115) 116string(7) "changed" 117Array 118( 119 [0] => done 120 [1] => changed 121 [2] => ref 122 [3] => A Object 123 ( 124 [obj] => changed 125 ) 126 127) 128string(7) "changed" 129string(7) "changed" 130 131Fatal error: Uncaught Error: ref(): Argument #1 ($b) could not be passed by reference in %soptimize_func_calls.php:%d 132Stack trace: 133#0 {main} 134 thrown in %soptimize_func_calls.php on line %d 135