1--TEST--
2Test current() function : usage variations - arrays containing different data types
3--FILE--
4<?php
5/*
6 * Pass arrays of different data types as $array_arg to current() to test behaviour
7 */
8
9echo "*** Testing current() : usage variations ***\n";
10
11//get an unset variable
12$unset_var = 10;
13unset ($unset_var);
14
15// get a class
16class classA
17{
18  public function __toString() {
19    return "Class A object";
20  }
21}
22
23// heredoc string
24$heredoc = <<<EOT
25hello world
26EOT;
27
28// get a resource variable
29$fp = fopen(__FILE__, "r");
30
31// arrays of different data types to be passed to $array_arg argument
32$inputs = array(
33
34       // int data
35/*1*/  'int' => array(
36       0,
37       1,
38       12345,
39       -2345,
40       ),
41
42       // float data
43/*2*/  'float' => array(
44       10.5,
45       -10.5,
46       12.3456789000e10,
47       12.3456789000E-10,
48       .5,
49       ),
50
51       // null data
52/*3*/ 'null' => array(
53       NULL,
54       null,
55       ),
56
57       // boolean data
58/*4*/ 'bool' => array(
59       true,
60       false,
61       TRUE,
62       FALSE,
63       ),
64
65       // empty data
66/*5*/ 'empty string' => array(
67       "",
68       '',
69       ),
70
71/*6*/ 'empty array' => array(
72       ),
73
74       // string data
75/*7*/ 'string' => array(
76       "string",
77       'string',
78       $heredoc,
79       ),
80
81       // object data
82/*8*/ 'object' => array(
83       new classA(),
84       ),
85
86       // undefined data
87/*9*/ 'undefined' => array(
88       @$undefined_var,
89       ),
90
91       // unset data
92/*10*/ 'unset' => array(
93       @$unset_var,
94       ),
95
96       // resource variable
97/*11*/ 'resource' => array(
98       $fp
99       ),
100);
101
102// loop through each element of $inputs to check the behavior of current()
103$iterator = 1;
104foreach($inputs as $key => $input) {
105  echo "\n-- Iteration $iterator : $key data --\n";
106  var_dump( current($input) );
107  $iterator++;
108};
109
110fclose($fp);
111?>
112--EXPECTF--
113*** Testing current() : usage variations ***
114
115-- Iteration 1 : int data --
116int(0)
117
118-- Iteration 2 : float data --
119float(10.5)
120
121-- Iteration 3 : null data --
122NULL
123
124-- Iteration 4 : bool data --
125bool(true)
126
127-- Iteration 5 : empty string data --
128string(0) ""
129
130-- Iteration 6 : empty array data --
131bool(false)
132
133-- Iteration 7 : string data --
134string(6) "string"
135
136-- Iteration 8 : object data --
137object(classA)#%d (0) {
138}
139
140-- Iteration 9 : undefined data --
141NULL
142
143-- Iteration 10 : unset data --
144NULL
145
146-- Iteration 11 : resource data --
147resource(%d) of type (stream)
148