Annotation of embedaddon/php/ext/standard/tests/array/array_walk_error2.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: Test array_walk() function : error conditions - callback parameters
! 3: --FILE--
! 4: <?php
! 5: /* Prototype : bool array_walk(array $input, string $funcname [, mixed $userdata])
! 6: * Description: Apply a user function to every member of an array
! 7: * Source code: ext/standard/array.c
! 8: */
! 9:
! 10: /*
! 11: * Testing array_walk() by passing more number of parameters to callback function
! 12: */
! 13: $input = array(1);
! 14:
! 15: function callback1($value, $key, $user_data ) {
! 16: echo "\ncallback1() invoked \n";
! 17: }
! 18:
! 19: function callback2($value, $key, $user_data1, $user_data2) {
! 20: echo "\ncallback2() invoked \n";
! 21: }
! 22: echo "*** Testing array_walk() : error conditions - callback parameters ***\n";
! 23:
! 24: // expected: Missing argument Warning
! 25: var_dump( array_walk($input, "callback1") );
! 26: var_dump( array_walk($input, "callback2", 4) );
! 27:
! 28: // expected: Warning is supressed
! 29: var_dump( @array_walk($input, "callback1") );
! 30: var_dump( @array_walk($input, "callback2", 4) );
! 31:
! 32: echo "-- Testing array_walk() function with too many callback parameters --\n";
! 33: var_dump( array_walk($input, "callback1", 20, 10) );
! 34:
! 35: echo "Done";
! 36: ?>
! 37: --EXPECTF--
! 38: *** Testing array_walk() : error conditions - callback parameters ***
! 39:
! 40: Warning: Missing argument 3 for callback1() in %s on line %d
! 41:
! 42: callback1() invoked
! 43: bool(true)
! 44:
! 45: Warning: Missing argument 4 for callback2() in %s on line %d
! 46:
! 47: callback2() invoked
! 48: bool(true)
! 49:
! 50: callback1() invoked
! 51: bool(true)
! 52:
! 53: callback2() invoked
! 54: bool(true)
! 55: -- Testing array_walk() function with too many callback parameters --
! 56:
! 57: Warning: array_walk() expects at most 3 parameters, 4 given in %s on line %d
! 58: NULL
! 59: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>