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

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

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