1--TEST--
2Returning a reference from a 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
17echo "\n---> 1. Trying to assign by reference the return value of a function that returns by value:\n";
18unset($a, $b);
19$a = 4;
20$b = &returnConstantByValue();
21$a++;
22var_dump($a, $b);
23
24echo "\n---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:\n";
25unset($a, $b);
26$a = 4;
27$b = &returnConstantByRef();
28$a++;
29var_dump($a, $b);
30
31echo "\n---> 3. Trying to assign by reference the return value of a function that returns by ref:\n";
32unset($a, $b);
33$a = 4;
34$b = &returnVariableByRef();
35$a++;
36var_dump($a, $b);
37
38?>
39--EXPECTF--
40---> 1. Trying to assign by reference the return value of a function that returns by value:
41
42Notice: Only variables should be assigned by reference in %s on line 17
43int(5)
44int(100)
45
46---> 2. Trying to assign by reference the return value of a function that returns a constant by ref:
47
48Notice: Only variable references should be returned by reference in %s on line 7
49int(5)
50int(100)
51
52---> 3. Trying to assign by reference the return value of a function that returns by ref:
53int(5)
54int(5)
55