1--TEST-- 2Test array_intersect_ukey() function : usage variation - Passing unexpected values to first argument 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 10echo "*** Testing array_intersect_ukey() : usage variation ***\n"; 11 12//Initialise arguments 13$array2 = array('green' => 5, 'blue' => 6, 'yellow' => 7, 'cyan' => 8); 14$array3 = array('green' => 5, 'cyan' => 8); 15 16//Call back function 17function key_compare_func($key1, $key2) 18{ 19 if ($key1 == $key2) 20 return 0; 21 else 22 return ($key1 > $key2)? 1:-1; 23} 24 25//get an unset variable 26$unset_var = 10; 27unset ($unset_var); 28 29//resource variable 30$fp = fopen(__FILE__, "r"); 31 32// define some classes 33class classWithToString 34{ 35 public function __toString() { 36 return "Class A object"; 37 } 38} 39 40class classWithoutToString 41{ 42} 43 44// heredoc string 45$heredoc = <<<EOT 46hello world 47EOT; 48 49//array of values to iterate over 50$inputs = array( 51 52 // int data 53 'int 0' => 0, 54 'int 1' => 1, 55 'int 12345' => 12345, 56 'int -12345' => -12345, 57 58 // float data 59 'float 10.5' => 10.5, 60 'float -10.5' => -10.5, 61 'float 12.3456789000e10' => 12.3456789000e10, 62 'float -12.3456789000e10' => -12.3456789000e10, 63 'float .5' => .5, 64 65 // null data 66 'uppercase NULL' => NULL, 67 'lowercase null' => null, 68 69 // boolean data 70 'lowercase true' => true, 71 'lowercase false' =>false, 72 'uppercase TRUE' =>TRUE, 73 'uppercase FALSE' =>FALSE, 74 75 // empty data 76 'empty string DQ' => "", 77 'empty string SQ' => '', 78 79 // string data 80 'string DQ' => "string", 81 'string SQ' => 'string', 82 'mixed case string' => "sTrInG", 83 'heredoc' => $heredoc, 84 85 // object data 86 'instance of classWithToString' => new classWithToString(), 87 'instance of classWithoutToString' => new classWithoutToString(), 88 89 // undefined data 90 'undefined var' => @$undefined_var, 91 92 // unset data 93 'unset var' => @$unset_var, 94 95 // resource data 96 'resource var' => $fp, 97); 98 99// loop through each element of the array for arr1 100 101foreach($inputs as $key =>$value) { 102 echo "\n--$key--\n"; 103 var_dump( array_intersect_ukey($value, $array2, 'key_compare_func') ); 104 var_dump( array_intersect_ukey($value, $array2, $array3, 'key_compare_func') ); 105}; 106 107fclose($fp); 108?> 109===DONE=== 110--EXPECTF-- 111*** Testing array_intersect_ukey() : usage variation *** 112 113--int 0-- 114 115Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 116NULL 117 118Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 119NULL 120 121--int 1-- 122 123Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 124NULL 125 126Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 127NULL 128 129--int 12345-- 130 131Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 132NULL 133 134Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 135NULL 136 137--int -12345-- 138 139Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 140NULL 141 142Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 143NULL 144 145--float 10.5-- 146 147Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 148NULL 149 150Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 151NULL 152 153--float -10.5-- 154 155Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 156NULL 157 158Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 159NULL 160 161--float 12.3456789000e10-- 162 163Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 164NULL 165 166Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 167NULL 168 169--float -12.3456789000e10-- 170 171Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 172NULL 173 174Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 175NULL 176 177--float .5-- 178 179Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 180NULL 181 182Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 183NULL 184 185--uppercase NULL-- 186 187Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 188NULL 189 190Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 191NULL 192 193--lowercase null-- 194 195Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 196NULL 197 198Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 199NULL 200 201--lowercase true-- 202 203Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 204NULL 205 206Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 207NULL 208 209--lowercase false-- 210 211Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 212NULL 213 214Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 215NULL 216 217--uppercase TRUE-- 218 219Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 220NULL 221 222Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 223NULL 224 225--uppercase FALSE-- 226 227Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 228NULL 229 230Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 231NULL 232 233--empty string DQ-- 234 235Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 236NULL 237 238Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 239NULL 240 241--empty string SQ-- 242 243Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 244NULL 245 246Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 247NULL 248 249--string DQ-- 250 251Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 252NULL 253 254Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 255NULL 256 257--string SQ-- 258 259Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 260NULL 261 262Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 263NULL 264 265--mixed case string-- 266 267Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 268NULL 269 270Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 271NULL 272 273--heredoc-- 274 275Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 276NULL 277 278Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 279NULL 280 281--instance of classWithToString-- 282 283Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 284NULL 285 286Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 287NULL 288 289--instance of classWithoutToString-- 290 291Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 292NULL 293 294Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 295NULL 296 297--undefined var-- 298 299Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 300NULL 301 302Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 303NULL 304 305--unset var-- 306 307Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 308NULL 309 310Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 311NULL 312 313--resource var-- 314 315Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 316NULL 317 318Warning: array_intersect_ukey(): Argument #1 is not an array in %s on line %d 319NULL 320===DONE=== 321