remove array_multisort and convert array_multisortN to use inout
[hiphop-php.git] / hphp / test / zend / good / ext / standard / tests / array / array_reverse_variation2.php
blobadeae787e3695794a417adc42c4450d6d597bdcc
1 <?hh
2 /* Prototype : array array_reverse(array $array [, bool $preserve_keys])
3 * Description: Return input as a new array with the order of the entries reversed
4 * Source code: ext/standard/array.c
5 */
7 /*
8 * testing the functionality of array_reverse() by giving unexpected values for $preserve_keys argument
9 */
11 //get a class
12 class classA
14 public function __toString(){
15 return "Class A object";
18 <<__EntryPoint>> function main(): void {
19 echo "*** Testing array_reverse() : usage variations ***\n";
21 // Initialise the array
22 $array = array("a" => "green", "red", "blue", "red", "orange", "pink");
24 //get an unset variable
25 $unset_var = 10;
26 unset ($unset_var);
28 //get a resource variable
29 $fp = fopen(__FILE__, "r");
31 //array of values to iterate over
32 $preserve_keys = array (
34 // int data
35 /*1*/ 0,
37 12345,
38 -2345,
40 // float data
41 /*5*/ 10.5,
42 -10.5,
43 10.5e10,
44 10.6E-10,
45 .5,
47 // array data
48 /*10*/ array(),
49 array(0),
50 array(1),
51 array(1, 2),
52 array('color' => 'red', 'item' => 'pen'),
54 // null data
55 /*15*/ NULL,
56 null,
58 // boolean data
59 true,
60 false,
61 TRUE,
62 FALSE,
64 // empty data
65 /*21*/
66 "",
67 '',
69 // object data
70 new classA(),
72 // undefined data
73 @$undefined_var,
75 // unset data
76 @$unset_var,
78 // resource variable
79 /*26*/ $fp
83 // loop through each element of the array $preserve_keys to check the behavior of array_reverse()
84 $iterator = 1;
85 foreach($preserve_keys as $preserve_key) {
86 echo "-- Iteration $iterator --\n";
87 try { var_dump( array_reverse($array, $preserve_key) ); } catch (Exception $e) { echo "\n".'Warning: '.$e->getMessage().' in '.__FILE__.' on line '.__LINE__."\n"; }
88 $iterator++;
91 // close the file resouce used
92 fclose($fp);
94 echo "Done";