import zend standard tests
[hiphop-php.git] / hphp / test / zend / bad / ext-standard-array / array_intersect_assoc_variation2.php
blob7ebdcadde0d2a2b6f8a81a619fba43997a9f347f
1 <?php
2 /* Prototype : array array_intersect_assoc(array $arr1, array $arr2 [, array $...])
3 * Description: Returns the entries of arr1 that have values which are present in all the other arguments.
4 * Keys are used to do more restrictive check
5 * Source code: ext/standard/array.c
6 */
8 /*
9 * Testing array_intersect_assoc() function by passing values to $arr2 argument other than arrays
10 * and see that function emits proper warning messages wherever expected.
11 * The $arr1 argument passed is a fixed array.
14 echo "*** Testing array_intersect_assoc() : Passing non-array values to \$arr2 argument ***\n";
16 // array to be passsed to $arr1 as default argument
17 $arr1 = array(1, 2);
19 // additional array to be passed for intersection
20 $arr3 = array(1, 2, "one" => 1, "two" => 2);
22 // get an unset variable
23 $unset_var = 10;
24 unset ($unset_var);
26 // get a class
27 class classA
29 public function __toString() {
30 return "Class A object";
34 // heredoc string
35 $heredoc = <<<EOT
36 hello world
37 EOT;
39 // get a resource variable
40 $fp = fopen(__FILE__, "r");
42 // unexpected values to be passed to $arr2 argument
43 $arrays = array(
45 // int data
46 /*1*/ 0,
48 12345,
49 -2345,
51 // float data
52 /*5*/ 10.5,
53 -10.5,
54 12.3456789000e10,
55 12.3456789000E-10,
56 .5,
58 // null data
59 /*10*/ NULL,
60 null,
62 // boolean data
63 /*12*/ true,
64 false,
65 TRUE,
66 FALSE,
68 // empty data
69 /*16*/ "",
70 '',
72 // string data
73 /*18*/ "string",
74 'string',
75 $heredoc,
77 // object data
78 /*21*/ new classA(),
80 // undefined data
81 /*22*/ @$undefined_var,
83 // unset data
84 /*23*/ @$unset_var,
86 // resource variable
87 /*24*/ $fp
90 // loop through each sub-array within $arrrays to check the behavior of array_intersect_assoc()
91 $iterator = 1;
92 foreach($arrays as $unexpected_value) {
93 echo "\n-- Iteration $iterator --";
95 // Calling array_intersect_assoc() with default arguments
96 var_dump( array_intersect_assoc($arr1,$unexpected_value) );
98 // Calling array_intersect_assoc() with more arguments
99 var_dump( array_intersect_assoc($arr1, $unexpected_value, $arr3) );
101 $iterator++;
104 // close the file resource used
105 fclose($fp);
107 echo "Done";