1--TEST--
2Returning a reference from a non-static method via another non-static method
3--FILE--
4<?php
5class C {
6	function returnConstantByValue() {
7		return 100;
8	}
9
10	function &returnConstantByRef() {
11		return 100;
12	}
13
14	function &returnVariableByRef() {
15		return $GLOBALS['a'];
16	}
17
18	function &returnFunctionCallByRef($functionToCall) {
19		return $this->$functionToCall();
20	}
21}
22$c = new C;
23
24echo "\n---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:\n";
25unset($a, $b);
26$a = 4;
27$b = &$c->returnFunctionCallByRef('returnConstantByValue');
28$a++;
29var_dump($a, $b);
30
31echo "\n---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:\n";
32unset($a, $b);
33$a = 4;
34$b = &$c->returnFunctionCallByRef('returnConstantByRef');
35$a++;
36var_dump($a, $b);
37
38echo "\n---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:\n";
39unset($a, $b);
40$a = 4;
41$b = &$c->returnFunctionCallByRef('returnVariableByRef');
42$a++;
43var_dump($a, $b);
44
45?>
46--EXPECTF--
47---> 1. Via a return by ref function call, assign by reference the return value of a function that returns by value:
48
49Notice: Only variable references should be returned by reference in %s on line 16
50int(5)
51int(100)
52
53---> 2. Via a return by ref function call, assign by reference the return value of a function that returns a constant by ref:
54
55Notice: Only variable references should be returned by reference in %s on line 8
56int(5)
57int(100)
58
59---> 3. Via a return by ref function call, assign by reference the return value of a function that returns by ref:
60int(5)
61int(5)
62