1--TEST--
2Test token_get_all() function : usage variations - with different arithmetic operators
3--FILE--
4<?php
5/* Prototype  : array token_get_all(string $source)
6 * Description: splits the given source into an array of PHP languange tokens
7 * Source code: ext/tokenizer/tokenizer.c
8*/
9
10/*
11 * Passing 'source' argument with different arithmetic operators to test them for token
12 * Arithmetic operators: +, -, *, /, % are not listed as specific operator tokens,
13 *    so they are expected to return string - T_STRING
14*/
15
16echo "*** Testing token_get_all() : 'source' string with different arithmetic operators ***\n";
17
18// arithmetic operators - '+', '-', '*', '/', '%'
19$source = array (
20  '<?php $a = 1 + 2; ?>',
21  '<?php $b = $b - 2; ?>',
22  '<?php $c = $a * $b; ?>',
23  '<?php $a = $b % 2; ?>'
24);
25for($count = 0; $count < count($source); $count++) {
26  echo "-- Iteration ".($count + 1)." --\n";
27  var_dump( token_get_all($source[$count]));
28}
29echo "Done"
30?>
31--EXPECTF--
32*** Testing token_get_all() : 'source' string with different arithmetic operators ***
33-- Iteration 1 --
34array(13) {
35  [0]=>
36  array(3) {
37    [0]=>
38    int(368)
39    [1]=>
40    string(6) "<?php "
41    [2]=>
42    int(1)
43  }
44  [1]=>
45  array(3) {
46    [0]=>
47    int(309)
48    [1]=>
49    string(2) "$a"
50    [2]=>
51    int(1)
52  }
53  [2]=>
54  array(3) {
55    [0]=>
56    int(371)
57    [1]=>
58    string(1) " "
59    [2]=>
60    int(1)
61  }
62  [3]=>
63  string(1) "="
64  [4]=>
65  array(3) {
66    [0]=>
67    int(371)
68    [1]=>
69    string(1) " "
70    [2]=>
71    int(1)
72  }
73  [5]=>
74  array(3) {
75    [0]=>
76    int(305)
77    [1]=>
78    string(1) "1"
79    [2]=>
80    int(1)
81  }
82  [6]=>
83  array(3) {
84    [0]=>
85    int(371)
86    [1]=>
87    string(1) " "
88    [2]=>
89    int(1)
90  }
91  [7]=>
92  string(1) "+"
93  [8]=>
94  array(3) {
95    [0]=>
96    int(371)
97    [1]=>
98    string(1) " "
99    [2]=>
100    int(1)
101  }
102  [9]=>
103  array(3) {
104    [0]=>
105    int(305)
106    [1]=>
107    string(1) "2"
108    [2]=>
109    int(1)
110  }
111  [10]=>
112  string(1) ";"
113  [11]=>
114  array(3) {
115    [0]=>
116    int(371)
117    [1]=>
118    string(1) " "
119    [2]=>
120    int(1)
121  }
122  [12]=>
123  array(3) {
124    [0]=>
125    int(370)
126    [1]=>
127    string(2) "?>"
128    [2]=>
129    int(1)
130  }
131}
132-- Iteration 2 --
133array(13) {
134  [0]=>
135  array(3) {
136    [0]=>
137    int(368)
138    [1]=>
139    string(6) "<?php "
140    [2]=>
141    int(1)
142  }
143  [1]=>
144  array(3) {
145    [0]=>
146    int(309)
147    [1]=>
148    string(2) "$b"
149    [2]=>
150    int(1)
151  }
152  [2]=>
153  array(3) {
154    [0]=>
155    int(371)
156    [1]=>
157    string(1) " "
158    [2]=>
159    int(1)
160  }
161  [3]=>
162  string(1) "="
163  [4]=>
164  array(3) {
165    [0]=>
166    int(371)
167    [1]=>
168    string(1) " "
169    [2]=>
170    int(1)
171  }
172  [5]=>
173  array(3) {
174    [0]=>
175    int(309)
176    [1]=>
177    string(2) "$b"
178    [2]=>
179    int(1)
180  }
181  [6]=>
182  array(3) {
183    [0]=>
184    int(371)
185    [1]=>
186    string(1) " "
187    [2]=>
188    int(1)
189  }
190  [7]=>
191  string(1) "-"
192  [8]=>
193  array(3) {
194    [0]=>
195    int(371)
196    [1]=>
197    string(1) " "
198    [2]=>
199    int(1)
200  }
201  [9]=>
202  array(3) {
203    [0]=>
204    int(305)
205    [1]=>
206    string(1) "2"
207    [2]=>
208    int(1)
209  }
210  [10]=>
211  string(1) ";"
212  [11]=>
213  array(3) {
214    [0]=>
215    int(371)
216    [1]=>
217    string(1) " "
218    [2]=>
219    int(1)
220  }
221  [12]=>
222  array(3) {
223    [0]=>
224    int(370)
225    [1]=>
226    string(2) "?>"
227    [2]=>
228    int(1)
229  }
230}
231-- Iteration 3 --
232array(13) {
233  [0]=>
234  array(3) {
235    [0]=>
236    int(368)
237    [1]=>
238    string(6) "<?php "
239    [2]=>
240    int(1)
241  }
242  [1]=>
243  array(3) {
244    [0]=>
245    int(309)
246    [1]=>
247    string(2) "$c"
248    [2]=>
249    int(1)
250  }
251  [2]=>
252  array(3) {
253    [0]=>
254    int(371)
255    [1]=>
256    string(1) " "
257    [2]=>
258    int(1)
259  }
260  [3]=>
261  string(1) "="
262  [4]=>
263  array(3) {
264    [0]=>
265    int(371)
266    [1]=>
267    string(1) " "
268    [2]=>
269    int(1)
270  }
271  [5]=>
272  array(3) {
273    [0]=>
274    int(309)
275    [1]=>
276    string(2) "$a"
277    [2]=>
278    int(1)
279  }
280  [6]=>
281  array(3) {
282    [0]=>
283    int(371)
284    [1]=>
285    string(1) " "
286    [2]=>
287    int(1)
288  }
289  [7]=>
290  string(1) "*"
291  [8]=>
292  array(3) {
293    [0]=>
294    int(371)
295    [1]=>
296    string(1) " "
297    [2]=>
298    int(1)
299  }
300  [9]=>
301  array(3) {
302    [0]=>
303    int(309)
304    [1]=>
305    string(2) "$b"
306    [2]=>
307    int(1)
308  }
309  [10]=>
310  string(1) ";"
311  [11]=>
312  array(3) {
313    [0]=>
314    int(371)
315    [1]=>
316    string(1) " "
317    [2]=>
318    int(1)
319  }
320  [12]=>
321  array(3) {
322    [0]=>
323    int(370)
324    [1]=>
325    string(2) "?>"
326    [2]=>
327    int(1)
328  }
329}
330-- Iteration 4 --
331array(13) {
332  [0]=>
333  array(3) {
334    [0]=>
335    int(368)
336    [1]=>
337    string(6) "<?php "
338    [2]=>
339    int(1)
340  }
341  [1]=>
342  array(3) {
343    [0]=>
344    int(309)
345    [1]=>
346    string(2) "$a"
347    [2]=>
348    int(1)
349  }
350  [2]=>
351  array(3) {
352    [0]=>
353    int(371)
354    [1]=>
355    string(1) " "
356    [2]=>
357    int(1)
358  }
359  [3]=>
360  string(1) "="
361  [4]=>
362  array(3) {
363    [0]=>
364    int(371)
365    [1]=>
366    string(1) " "
367    [2]=>
368    int(1)
369  }
370  [5]=>
371  array(3) {
372    [0]=>
373    int(309)
374    [1]=>
375    string(2) "$b"
376    [2]=>
377    int(1)
378  }
379  [6]=>
380  array(3) {
381    [0]=>
382    int(371)
383    [1]=>
384    string(1) " "
385    [2]=>
386    int(1)
387  }
388  [7]=>
389  string(1) "%"
390  [8]=>
391  array(3) {
392    [0]=>
393    int(371)
394    [1]=>
395    string(1) " "
396    [2]=>
397    int(1)
398  }
399  [9]=>
400  array(3) {
401    [0]=>
402    int(305)
403    [1]=>
404    string(1) "2"
405    [2]=>
406    int(1)
407  }
408  [10]=>
409  string(1) ";"
410  [11]=>
411  array(3) {
412    [0]=>
413    int(371)
414    [1]=>
415    string(1) " "
416    [2]=>
417    int(1)
418  }
419  [12]=>
420  array(3) {
421    [0]=>
422    int(370)
423    [1]=>
424    string(2) "?>"
425    [2]=>
426    int(1)
427  }
428}
429Done
430