1--TEST--
2Test token_get_all() function : usage variations - with increment/decrement operators
3--SKIPIF--
4<?php if (!extension_loaded("tokenizer")) print "skip"; ?>
5--FILE--
6<?php
7/* Prototype  : array token_get_all(string $source)
8 * Description: splits the given source into an array of PHP languange tokens
9 * Source code: ext/tokenizer/tokenizer.c
10*/
11
12/*
13 * Passing 'source' argument with different increment/decrement operators to test them for token
14 *  ++ - T_INC(297)
15 *  -- - T_DEC(296)
16*/
17
18echo "*** Testing token_get_all() : 'source' string with different increment/decrement operators ***\n";
19
20// increment/decrement operators : '++' , '--'
21$source = '<?php
22$a = 10, $b = 5;
23$a++;
24$b--;
25echo $a;
26?>';
27var_dump( token_get_all($source));
28
29echo "Done"
30?>
31--EXPECTF--
32*** Testing token_get_all() : 'source' string with different increment/decrement operators ***
33array(30) {
34  [0]=>
35  array(3) {
36    [0]=>
37    int(%d)
38    [1]=>
39    string(6) "<?php "
40    [2]=>
41    int(1)
42  }
43  [1]=>
44  array(3) {
45    [0]=>
46    int(%d)
47    [1]=>
48    string(1) "
49"
50    [2]=>
51    int(1)
52  }
53  [2]=>
54  array(3) {
55    [0]=>
56    int(%d)
57    [1]=>
58    string(2) "$a"
59    [2]=>
60    int(2)
61  }
62  [3]=>
63  array(3) {
64    [0]=>
65    int(%d)
66    [1]=>
67    string(1) " "
68    [2]=>
69    int(2)
70  }
71  [4]=>
72  string(1) "="
73  [5]=>
74  array(3) {
75    [0]=>
76    int(%d)
77    [1]=>
78    string(1) " "
79    [2]=>
80    int(2)
81  }
82  [6]=>
83  array(3) {
84    [0]=>
85    int(%d)
86    [1]=>
87    string(2) "10"
88    [2]=>
89    int(2)
90  }
91  [7]=>
92  string(1) ","
93  [8]=>
94  array(3) {
95    [0]=>
96    int(%d)
97    [1]=>
98    string(1) " "
99    [2]=>
100    int(2)
101  }
102  [9]=>
103  array(3) {
104    [0]=>
105    int(%d)
106    [1]=>
107    string(2) "$b"
108    [2]=>
109    int(2)
110  }
111  [10]=>
112  array(3) {
113    [0]=>
114    int(%d)
115    [1]=>
116    string(1) " "
117    [2]=>
118    int(2)
119  }
120  [11]=>
121  string(1) "="
122  [12]=>
123  array(3) {
124    [0]=>
125    int(%d)
126    [1]=>
127    string(1) " "
128    [2]=>
129    int(2)
130  }
131  [13]=>
132  array(3) {
133    [0]=>
134    int(%d)
135    [1]=>
136    string(1) "5"
137    [2]=>
138    int(2)
139  }
140  [14]=>
141  string(1) ";"
142  [15]=>
143  array(3) {
144    [0]=>
145    int(%d)
146    [1]=>
147    string(1) "
148"
149    [2]=>
150    int(2)
151  }
152  [16]=>
153  array(3) {
154    [0]=>
155    int(%d)
156    [1]=>
157    string(2) "$a"
158    [2]=>
159    int(%d)
160  }
161  [17]=>
162  array(3) {
163    [0]=>
164    int(%d)
165    [1]=>
166    string(2) "++"
167    [2]=>
168    int(%d)
169  }
170  [18]=>
171  string(1) ";"
172  [19]=>
173  array(3) {
174    [0]=>
175    int(%d)
176    [1]=>
177    string(1) "
178"
179    [2]=>
180    int(%d)
181  }
182  [20]=>
183  array(3) {
184    [0]=>
185    int(%d)
186    [1]=>
187    string(2) "$b"
188    [2]=>
189    int(4)
190  }
191  [21]=>
192  array(3) {
193    [0]=>
194    int(%d)
195    [1]=>
196    string(2) "--"
197    [2]=>
198    int(4)
199  }
200  [22]=>
201  string(1) ";"
202  [23]=>
203  array(3) {
204    [0]=>
205    int(%d)
206    [1]=>
207    string(1) "
208"
209    [2]=>
210    int(4)
211  }
212  [24]=>
213  array(3) {
214    [0]=>
215    int(%d)
216    [1]=>
217    string(4) "echo"
218    [2]=>
219    int(5)
220  }
221  [25]=>
222  array(3) {
223    [0]=>
224    int(%d)
225    [1]=>
226    string(1) " "
227    [2]=>
228    int(5)
229  }
230  [26]=>
231  array(3) {
232    [0]=>
233    int(%d)
234    [1]=>
235    string(2) "$a"
236    [2]=>
237    int(5)
238  }
239  [27]=>
240  string(1) ";"
241  [28]=>
242  array(3) {
243    [0]=>
244    int(%d)
245    [1]=>
246    string(1) "
247"
248    [2]=>
249    int(5)
250  }
251  [29]=>
252  array(3) {
253    [0]=>
254    int(%d)
255    [1]=>
256    string(2) "?>"
257    [2]=>
258    int(6)
259  }
260}
261Done
262