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