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