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