1--TEST--
2Test 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
15function callback1($value, $key, $user_data ) {
16  echo "\ncallback1() invoked \n";
17}
18
19function callback2($value, $key, $user_data1, $user_data2) {
20  echo "\ncallback2() invoked \n";
21}
22echo "*** Testing array_walk() : error conditions - callback parameters ***\n";
23
24// expected: Missing argument Warning
25var_dump( array_walk($input, "callback1") );
26var_dump( array_walk($input, "callback2", 4) );
27
28// expected: Warning is suppressed
29var_dump( @array_walk($input, "callback1") );
30var_dump( @array_walk($input, "callback2", 4) );
31
32echo "-- Testing array_walk() function with too many callback parameters --\n";
33var_dump( array_walk($input, "callback1", 20, 10) );
34
35echo "Done";
36?>
37--EXPECTF--
38*** Testing array_walk() : error conditions - callback parameters ***
39
40Warning: Missing argument 3 for callback1() in %s on line %d
41
42callback1() invoked
43bool(true)
44
45Warning: Missing argument 4 for callback2() in %s on line %d
46
47callback2() invoked
48bool(true)
49
50callback1() invoked
51bool(true)
52
53callback2() invoked
54bool(true)
55-- Testing array_walk() function with too many callback parameters --
56
57Warning: array_walk() expects at most 3 parameters, 4 given in %s on line %d
58NULL
59Done
60