1--TEST-- 2Test array_intersect_uassoc() function : usage variation - Passing unexpected values to first argument 3--FILE-- 4<?php 5echo "*** Testing array_intersect_uassoc() : usage variation ***\n"; 6 7// Initialise function arguments 8$array2 = array("a" => "green", "yellow", "red"); 9$array3 = array("a"=>"green", "brown"); 10 11//Callback function 12function key_compare_func($a, $b) { 13 if ($a === $b) { 14 return 0; 15 } 16 return ($a > $b) ? 1 : -1; 17} 18 19//get an unset variable 20$unset_var = 10; 21unset ($unset_var); 22 23//resource variable 24$fp = fopen(__FILE__, "r"); 25 26// define some classes 27class classWithToString 28{ 29 public function __toString() { 30 return "Class A object"; 31 } 32} 33 34class classWithoutToString 35{ 36} 37 38// heredoc string 39$heredoc = <<<EOT 40hello world 41EOT; 42 43// add arrays 44$index_array = array (1, 2, 3); 45$assoc_array = array ('one' => 1, 'two' => 2); 46 47//array of values to iterate over 48$inputs = array( 49 50 // int data 51 'int 0' => 0, 52 'int 1' => 1, 53 'int 12345' => 12345, 54 'int -12345' => -12345, 55 56 // float data 57 'float 10.5' => 10.5, 58 'float -10.5' => -10.5, 59 'float 12.3456789000e10' => 12.3456789000e10, 60 'float -12.3456789000e10' => -12.3456789000e10, 61 'float .5' => .5, 62 63 // null data 64 'uppercase NULL' => NULL, 65 'lowercase null' => null, 66 67 // boolean data 68 'lowercase true' => true, 69 'lowercase false' =>false, 70 'uppercase TRUE' =>TRUE, 71 'uppercase FALSE' =>FALSE, 72 73 // empty data 74 'empty string DQ' => "", 75 'empty string SQ' => '', 76 77 // string data 78 'string DQ' => "string", 79 'string SQ' => 'string', 80 'mixed case string' => "sTrInG", 81 'heredoc' => $heredoc, 82 83 // object data 84 'instance of classWithToString' => new classWithToString(), 85 'instance of classWithoutToString' => new classWithoutToString(), 86 87 // undefined data 88 'undefined var' => @$undefined_var, 89 90 // unset data 91 'unset var' => @$unset_var, 92 93 // resource data 94 'resource' => $fp, 95); 96 97// loop through each element of the array for array1 98foreach($inputs as $key =>$value) { 99 echo "\n--$key--\n"; 100 try { 101 var_dump( array_intersect_uassoc($value, $array2, 'key_compare_func') ); 102 } catch (TypeError $e) { 103 echo $e->getMessage(), "\n"; 104 } 105 try { 106 var_dump( array_intersect_uassoc($value, $array2, $array3, 'key_compare_func') ); 107 } catch (TypeError $e) { 108 echo $e->getMessage(), "\n"; 109 } 110}; 111 112fclose($fp); 113?> 114--EXPECT-- 115*** Testing array_intersect_uassoc() : usage variation *** 116 117--int 0-- 118array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 119array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 120 121--int 1-- 122array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 123array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 124 125--int 12345-- 126array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 127array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 128 129--int -12345-- 130array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 131array_intersect_uassoc(): Argument #1 ($array) must be of type array, int given 132 133--float 10.5-- 134array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 135array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 136 137--float -10.5-- 138array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 139array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 140 141--float 12.3456789000e10-- 142array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 143array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 144 145--float -12.3456789000e10-- 146array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 147array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 148 149--float .5-- 150array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 151array_intersect_uassoc(): Argument #1 ($array) must be of type array, float given 152 153--uppercase NULL-- 154array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 155array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 156 157--lowercase null-- 158array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 159array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 160 161--lowercase true-- 162array_intersect_uassoc(): Argument #1 ($array) must be of type array, true given 163array_intersect_uassoc(): Argument #1 ($array) must be of type array, true given 164 165--lowercase false-- 166array_intersect_uassoc(): Argument #1 ($array) must be of type array, false given 167array_intersect_uassoc(): Argument #1 ($array) must be of type array, false given 168 169--uppercase TRUE-- 170array_intersect_uassoc(): Argument #1 ($array) must be of type array, true given 171array_intersect_uassoc(): Argument #1 ($array) must be of type array, true given 172 173--uppercase FALSE-- 174array_intersect_uassoc(): Argument #1 ($array) must be of type array, false given 175array_intersect_uassoc(): Argument #1 ($array) must be of type array, false given 176 177--empty string DQ-- 178array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 179array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 180 181--empty string SQ-- 182array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 183array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 184 185--string DQ-- 186array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 187array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 188 189--string SQ-- 190array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 191array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 192 193--mixed case string-- 194array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 195array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 196 197--heredoc-- 198array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 199array_intersect_uassoc(): Argument #1 ($array) must be of type array, string given 200 201--instance of classWithToString-- 202array_intersect_uassoc(): Argument #1 ($array) must be of type array, classWithToString given 203array_intersect_uassoc(): Argument #1 ($array) must be of type array, classWithToString given 204 205--instance of classWithoutToString-- 206array_intersect_uassoc(): Argument #1 ($array) must be of type array, classWithoutToString given 207array_intersect_uassoc(): Argument #1 ($array) must be of type array, classWithoutToString given 208 209--undefined var-- 210array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 211array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 212 213--unset var-- 214array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 215array_intersect_uassoc(): Argument #1 ($array) must be of type array, null given 216 217--resource-- 218array_intersect_uassoc(): Argument #1 ($array) must be of type array, resource given 219array_intersect_uassoc(): Argument #1 ($array) must be of type array, resource given 220