Annotation of embedaddon/php/tests/lang/returnByReference.006.phpt, revision 1.1.1.1

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

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>