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