Annotation of embedaddon/php/ext/standard/tests/general_functions/call_user_func_array_variation_001.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: call_user_func_array() passes by reference if the array element is referenced, regardless of function signature.
! 3: --FILE--
! 4: <?php
! 5:
! 6: function by_val($arg) {
! 7: $arg = 'changed';
! 8: }
! 9:
! 10: function by_ref(&$arg) {
! 11: $arg = 'changed';
! 12: }
! 13:
! 14: echo "------ Calling by_val() with unreferenced argument ------\n";
! 15: $arg = array('original');
! 16: call_user_func_array('by_val', $arg);
! 17: var_dump($arg);
! 18:
! 19: echo "------ Calling by_ref() with unreferenced argument ------\n";
! 20: $arg = array('original');
! 21: call_user_func_array('by_ref', $arg);
! 22: var_dump($arg);
! 23:
! 24: echo "------ Calling by_val() with referenced argument ------\n";
! 25: $arg = array('original');
! 26: $ref = &$arg[0];
! 27: call_user_func_array('by_val', $arg);
! 28: var_dump($arg);
! 29:
! 30: echo "------ Calling by_ref() with referenced argument ------\n";
! 31: $arg = array('original');
! 32: $ref = &$arg[0];
! 33: call_user_func_array('by_ref', $arg);
! 34: var_dump($arg);
! 35:
! 36: ?>
! 37: --EXPECTF--
! 38: ------ Calling by_val() with unreferenced argument ------
! 39: array(1) {
! 40: [0]=>
! 41: string(8) "original"
! 42: }
! 43: ------ Calling by_ref() with unreferenced argument ------
! 44:
! 45: Warning: Parameter 1 to by_ref() expected to be a reference, value given in %s on line %d
! 46: array(1) {
! 47: [0]=>
! 48: string(8) "original"
! 49: }
! 50: ------ Calling by_val() with referenced argument ------
! 51: array(1) {
! 52: [0]=>
! 53: &string(7) "changed"
! 54: }
! 55: ------ Calling by_ref() with referenced argument ------
! 56: array(1) {
! 57: [0]=>
! 58: &string(7) "changed"
! 59: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>