1--TEST--
2Test array_reduce() function : variation
3--FILE--
4<?php
5/* Prototype  : mixed array_reduce(array input, mixed callback [, int initial])
6 * Description: Iteratively reduce the array to a single value via the callback.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_reduce() : variation ***\n";
12
13
14function oneArg($v) {
15  return $v;
16}
17
18function threeArgs($v, $w, $x) {
19  return $v + $w + $x;
20}
21
22$array = array(1);
23
24echo "\n--- Testing with a callback with too few parameters ---\n";
25var_dump(array_reduce($array, "oneArg", 2));
26
27echo "\n--- Testing with a callback with too many parameters ---\n";
28try {
29	var_dump(array_reduce($array, "threeArgs", 2));
30} catch (Throwable $e) {
31	echo "Exception: " . $e->getMessage() . "\n";
32}
33
34?>
35===DONE===
36--EXPECTF--
37*** Testing array_reduce() : variation ***
38
39--- Testing with a callback with too few parameters ---
40int(2)
41
42--- Testing with a callback with too many parameters ---
43Exception: Too few arguments to function threeArgs(), 2 passed and exactly 3 expected
44===DONE===
45