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