Added in some missing fields (columns) to watchman_events tables
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_diff_uassoc_variation1.php
blobb59bc5bb16d7719aec9dbff1550a5e80b599dc61
1 <?hh
2 /* Prototype : array array_diff_uassoc(array arr1, array arr2 [, array ...], callback key_comp_func)
3 * Description: Computes the difference of arrays with additional index check which is performed by a
4 * user supplied callback function
5 * Source code: ext/standard/array.c
6 */
8 // define some classes
9 class classWithToString
11 public function __toString() :mixed{
12 return "Class A object";
16 class classWithoutToString
20 function key_compare_func($a, $b)
21 :mixed{
22 if ($a === $b) {
23 return 0;
25 return ($a > $b)? 1:-1;
27 <<__EntryPoint>> function main(): void {
28 echo "*** Testing array_diff_uassoc() : usage variation ***\n";
30 //Initialize variables
31 $array2 = dict["a" => "green", 0 => "yellow", 1 => "red"];
34 //resource variable
35 $fp = fopen(__FILE__, "r");
37 // heredoc string
38 $heredoc = <<<EOT
39 hello world
40 EOT;
42 // add arrays
43 $index_array = vec[1, 2, 3];
44 $assoc_array = dict['one' => 1, 'two' => 2];
46 //array of values to iterate over
47 $inputs = dict[
49 // int data
50 'int 0' => 0,
51 'int 1' => 1,
52 'int 12345' => 12345,
53 'int -12345' => -2345,
55 // float data
56 'float 10.5' => 10.5,
57 'float -10.5' => -10.5,
58 'float 12.3456789000e10' => 12.3456789000e10,
59 'float -12.3456789000e10' => -12.3456789000e10,
60 'float .5' => .5,
62 // null data
63 'uppercase NULL' => NULL,
64 'lowercase null' => null,
66 // boolean data
67 'lowercase true' => true,
68 'lowercase false' =>false,
69 'uppercase TRUE' =>TRUE,
70 'uppercase FALSE' =>FALSE,
72 // empty data
73 'empty string DQ' => "",
74 'empty string SQ' => '',
76 // string data
77 'string DQ' => "string",
78 'string SQ' => 'string',
79 'mixed case string' => "sTrInG",
80 'heredoc' => $heredoc,
82 // object data
83 'instance of classWithToString' => new classWithToString(),
84 'instance of classWithoutToString' => new classWithoutToString(),
88 // resource data
89 'resource' => $fp,
92 // loop through each element of the array for arr1
94 foreach($inputs as $key =>$value) {
95 echo "\n--$key--\n";
96 var_dump( array_diff_uassoc($value, $array2, key_compare_func<>) );
99 fclose($fp);
100 echo "===DONE===\n";