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

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

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