Annotation of embedaddon/php/ext/standard/tests/array/array_intersect_ukey_variation10.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test array_intersect_ukey() function : usage variation - Passing class without string to callback (Handling fatal error)
3: --FILE--
4: <?php
5: /* Prototype : array array_intersect_ukey(array arr1, array arr2 [, array ...], callback key_compare_func)
6: * Description: Computes the intersection of arrays using a callback function on the keys for comparison.
7: * Source code: ext/standard/array.c
8: */
9:
10: echo "*** Testing array_intersect_uassoc() : usage variation ***\n";
11:
12: //Initialise arguments
13: $array1 = array('blue' => 1, 'red' => 2, 'green' => 3, 'purple' => 4);
14: $array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8);
15: $array3 = array("a"=>"green", "cyan");
16:
17: // Define error handler
18: function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
19: if (error_reporting() != 0) {
20: // report non-silenced errors
21: echo "Error: $err_no - $err_msg, $filename($linenum)\n";
22: }
23: }
24: set_error_handler('test_error_handler');
25:
26:
27: class classWithoutToString
28: {
29: }
30:
31: $value = new classWithoutToString();
32:
33: var_dump( array_intersect_ukey($array1, $array2, $value) );
34: var_dump( array_intersect_ukey($array1, $array2, $array3, $value) );
35: ?>
36: ===DONE===
37: --EXPECTF--
38: *** Testing array_intersect_uassoc() : usage variation ***
39: Error: 2 - array_intersect_ukey() expects parameter 3 to be a valid callback, no array or string given, %s(%d)
40: NULL
41: Error: 2 - array_intersect_ukey() expects parameter 4 to be a valid callback, no array or string given, %s(%d)
42: NULL
43: ===DONE===
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>