1--TEST--
2Test array_shift() function : usage variations - Pass array with different data types as keys
3--FILE--
4<?php
5/*
6 * Pass arrays with different data types as keys to test how array_shift() re-assigns keys
7 */
8
9echo "*** Testing array_shift() : usage variations ***\n";
10
11//get an unset variable
12$unset_var = 10;
13unset ($unset_var);
14
15// heredoc string
16$heredoc = <<<EOT
17hello world
18EOT;
19
20// unexpected values to be passed to $stack argument
21$inputs = array(
22
23       // int data
24/*1*/  'int' => array(
25       0 => 'zero',
26       1 => 'one',
27       12345 => 'positive',
28       -2345 => 'negative',
29       ),
30
31       // null data
32/*4*/  'null uppercase' => array(
33       NULL => 'null 1',
34       ),
35
36/*5*/  'null lowercase' => array(
37       null => 'null 2',
38       ),
39
40       // boolean data
41/*6*/  'bool lowercase' => array(
42       true => 'lowert',
43       false => 'lowerf',
44       ),
45
46/*7*/  'bool uppercase' => array(
47       TRUE => 'uppert',
48       FALSE => 'upperf',
49       ),
50
51       // empty data
52/*8*/  'empty double quotes' => array(
53       "" => 'emptyd',
54       ),
55
56/*9*/  'empty single quotes' => array(
57       '' => 'emptys',
58       ),
59
60       // string data
61/*10*/ 'string' => array(
62       "stringd" => 'stringd',
63       'strings' => 'strings',
64       $heredoc => 'stringh',
65       ),
66
67       // undefined data
68/*11*/ 'undefined' => array(
69       @$undefined_var => 'undefined',
70       ),
71
72       // unset data
73/*12*/ 'unset' => array(
74       @$unset_var => 'unset',
75       ),
76);
77
78// loop through each element of $inputs to check the behavior of array_shift()
79$iterator = 1;
80foreach($inputs as $key => $input) {
81  echo "\n-- Iteration $iterator : $key data --\n";
82  var_dump( array_shift($input) );
83  var_dump($input);
84  $iterator++;
85};
86
87echo "Done";
88?>
89--EXPECT--
90*** Testing array_shift() : usage variations ***
91
92-- Iteration 1 : int data --
93string(4) "zero"
94array(3) {
95  [0]=>
96  string(3) "one"
97  [1]=>
98  string(8) "positive"
99  [2]=>
100  string(8) "negative"
101}
102
103-- Iteration 2 : null uppercase data --
104string(6) "null 1"
105array(0) {
106}
107
108-- Iteration 3 : null lowercase data --
109string(6) "null 2"
110array(0) {
111}
112
113-- Iteration 4 : bool lowercase data --
114string(6) "lowert"
115array(1) {
116  [0]=>
117  string(6) "lowerf"
118}
119
120-- Iteration 5 : bool uppercase data --
121string(6) "uppert"
122array(1) {
123  [0]=>
124  string(6) "upperf"
125}
126
127-- Iteration 6 : empty double quotes data --
128string(6) "emptyd"
129array(0) {
130}
131
132-- Iteration 7 : empty single quotes data --
133string(6) "emptys"
134array(0) {
135}
136
137-- Iteration 8 : string data --
138string(7) "stringd"
139array(2) {
140  ["strings"]=>
141  string(7) "strings"
142  ["hello world"]=>
143  string(7) "stringh"
144}
145
146-- Iteration 9 : undefined data --
147string(9) "undefined"
148array(0) {
149}
150
151-- Iteration 10 : unset data --
152string(5) "unset"
153array(0) {
154}
155Done
156