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