1--TEST--
2Test array_udiff_uassoc() function : usage variation
3--FILE--
4<?php
5/* Prototype  : array array_udiff_uassoc(array arr1, array arr2 [, array ...], callback data_comp_func, callback key_comp_func)
6 * Description: Returns the entries of arr1 that have values which are not present in any of the others arguments but do additional checks whether the keys are equal. Keys and elements are compared by user supplied functions.
7 * Source code: ext/standard/array.c
8 * Alias to functions:
9 */
10
11echo "*** Testing array_udiff_uassoc() : usage variation - differing comparison functions***\n";
12
13$arr1 = array(1);
14$arr2 = array(1);
15
16echo "\n-- comparison function with an incorrect return value --\n";
17function incorrect_return_value ($val1, $val2) {
18  return array(1);
19}
20var_dump(array_udiff_uassoc($arr1, $arr2, 'incorrect_return_value', 'incorrect_return_value'));
21
22echo "\n-- comparison function taking too many parameters --\n";
23function too_many_parameters ($val1, $val2, $val3) {
24  return 1;
25}
26try {
27	var_dump(array_udiff_uassoc($arr1, $arr2, 'too_many_parameters', 'too_many_parameters'));
28} catch (Throwable $e) {
29	echo "Exception: " . $e->getMessage() . "\n";
30}
31
32echo "\n-- comparison function taking too few parameters --\n";
33function too_few_parameters ($val1) {
34  return 1;
35}
36var_dump(array_udiff_uassoc($arr1, $arr2, 'too_few_parameters', 'too_few_parameters'));
37
38?>
39===DONE===
40--EXPECT--
41*** Testing array_udiff_uassoc() : usage variation - differing comparison functions***
42
43-- comparison function with an incorrect return value --
44array(1) {
45  [0]=>
46  int(1)
47}
48
49-- comparison function taking too many parameters --
50Exception: Too few arguments to function too_many_parameters(), 2 passed and exactly 3 expected
51
52-- comparison function taking too few parameters --
53array(1) {
54  [0]=>
55  int(1)
56}
57===DONE===
58