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