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