1--TEST--
2Test token_get_all() function : usage variations - with type casting 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 type casting operators to test them for token
14 *  (int)/(integer) - T_INT_CAST(295), (float)/(real)/(double) - T_DOUBLE_CAST(294),
15 *  (string) - T_STRING_CAST(293), (bool)/(boolean) - T_BOOL_CAST(290),
16 *  (unset) - T_UNSET_CAST(289)
17*/
18
19echo "*** Testing token_get_all() : 'source' string with different type casting operators ***\n";
20
21// type casting operators : (int), (integer), (float), (real), (double), (string), (array), (object), (bool), (boolean),(unset)
22$source = '<?php
23$a = 1, $b = 10.5
24$c = (int)$b + $a;
25$d = (float)$a + $b;
26$e = (string)$a.(string)$b;
27if((bool)$a) echo "true";
28if(!(boolean)$b) echo "false";
29$c = $c + (integer) 123.4e2;
30$d = $c - (real) 12;
31$b = (unset)$a;
32?>';
33var_dump( token_get_all($source));
34
35echo "Done"
36?>
37--EXPECTF--
38*** Testing token_get_all() : 'source' string with different type casting operators ***
39array(108) {
40  [0]=>
41  array(3) {
42    [0]=>
43    int(%d)
44    [1]=>
45    string(6) "<?php "
46    [2]=>
47    int(1)
48  }
49  [1]=>
50  array(3) {
51    [0]=>
52    int(%d)
53    [1]=>
54    string(1) "
55"
56    [2]=>
57    int(1)
58  }
59  [2]=>
60  array(3) {
61    [0]=>
62    int(%d)
63    [1]=>
64    string(2) "$a"
65    [2]=>
66    int(2)
67  }
68  [3]=>
69  array(3) {
70    [0]=>
71    int(%d)
72    [1]=>
73    string(1) " "
74    [2]=>
75    int(2)
76  }
77  [4]=>
78  string(1) "="
79  [5]=>
80  array(3) {
81    [0]=>
82    int(%d)
83    [1]=>
84    string(1) " "
85    [2]=>
86    int(2)
87  }
88  [6]=>
89  array(3) {
90    [0]=>
91    int(%d)
92    [1]=>
93    string(1) "1"
94    [2]=>
95    int(2)
96  }
97  [7]=>
98  string(1) ","
99  [8]=>
100  array(3) {
101    [0]=>
102    int(%d)
103    [1]=>
104    string(1) " "
105    [2]=>
106    int(2)
107  }
108  [9]=>
109  array(3) {
110    [0]=>
111    int(%d)
112    [1]=>
113    string(2) "$b"
114    [2]=>
115    int(2)
116  }
117  [10]=>
118  array(3) {
119    [0]=>
120    int(%d)
121    [1]=>
122    string(1) " "
123    [2]=>
124    int(2)
125  }
126  [11]=>
127  string(1) "="
128  [12]=>
129  array(3) {
130    [0]=>
131    int(%d)
132    [1]=>
133    string(1) " "
134    [2]=>
135    int(2)
136  }
137  [13]=>
138  array(3) {
139    [0]=>
140    int(%d)
141    [1]=>
142    string(4) "10.5"
143    [2]=>
144    int(2)
145  }
146  [14]=>
147  array(3) {
148    [0]=>
149    int(%d)
150    [1]=>
151    string(1) "
152"
153    [2]=>
154    int(2)
155  }
156  [15]=>
157  array(3) {
158    [0]=>
159    int(%d)
160    [1]=>
161    string(2) "$c"
162    [2]=>
163    int(%d)
164  }
165  [16]=>
166  array(3) {
167    [0]=>
168    int(%d)
169    [1]=>
170    string(1) " "
171    [2]=>
172    int(%d)
173  }
174  [17]=>
175  string(1) "="
176  [18]=>
177  array(3) {
178    [0]=>
179    int(%d)
180    [1]=>
181    string(1) " "
182    [2]=>
183    int(%d)
184  }
185  [19]=>
186  array(3) {
187    [0]=>
188    int(%d)
189    [1]=>
190    string(5) "(int)"
191    [2]=>
192    int(%d)
193  }
194  [20]=>
195  array(3) {
196    [0]=>
197    int(%d)
198    [1]=>
199    string(2) "$b"
200    [2]=>
201    int(%d)
202  }
203  [21]=>
204  array(3) {
205    [0]=>
206    int(%d)
207    [1]=>
208    string(1) " "
209    [2]=>
210    int(%d)
211  }
212  [22]=>
213  string(1) "+"
214  [23]=>
215  array(3) {
216    [0]=>
217    int(%d)
218    [1]=>
219    string(1) " "
220    [2]=>
221    int(%d)
222  }
223  [24]=>
224  array(3) {
225    [0]=>
226    int(%d)
227    [1]=>
228    string(2) "$a"
229    [2]=>
230    int(%d)
231  }
232  [25]=>
233  string(1) ";"
234  [26]=>
235  array(3) {
236    [0]=>
237    int(%d)
238    [1]=>
239    string(1) "
240"
241    [2]=>
242    int(%d)
243  }
244  [27]=>
245  array(3) {
246    [0]=>
247    int(%d)
248    [1]=>
249    string(2) "$d"
250    [2]=>
251    int(4)
252  }
253  [28]=>
254  array(3) {
255    [0]=>
256    int(%d)
257    [1]=>
258    string(1) " "
259    [2]=>
260    int(4)
261  }
262  [29]=>
263  string(1) "="
264  [30]=>
265  array(3) {
266    [0]=>
267    int(%d)
268    [1]=>
269    string(1) " "
270    [2]=>
271    int(4)
272  }
273  [31]=>
274  array(3) {
275    [0]=>
276    int(%d)
277    [1]=>
278    string(7) "(float)"
279    [2]=>
280    int(4)
281  }
282  [32]=>
283  array(3) {
284    [0]=>
285    int(%d)
286    [1]=>
287    string(2) "$a"
288    [2]=>
289    int(4)
290  }
291  [33]=>
292  array(3) {
293    [0]=>
294    int(%d)
295    [1]=>
296    string(1) " "
297    [2]=>
298    int(4)
299  }
300  [34]=>
301  string(1) "+"
302  [35]=>
303  array(3) {
304    [0]=>
305    int(%d)
306    [1]=>
307    string(1) " "
308    [2]=>
309    int(4)
310  }
311  [36]=>
312  array(3) {
313    [0]=>
314    int(%d)
315    [1]=>
316    string(2) "$b"
317    [2]=>
318    int(4)
319  }
320  [37]=>
321  string(1) ";"
322  [38]=>
323  array(3) {
324    [0]=>
325    int(%d)
326    [1]=>
327    string(1) "
328"
329    [2]=>
330    int(4)
331  }
332  [39]=>
333  array(3) {
334    [0]=>
335    int(%d)
336    [1]=>
337    string(2) "$e"
338    [2]=>
339    int(5)
340  }
341  [40]=>
342  array(3) {
343    [0]=>
344    int(%d)
345    [1]=>
346    string(1) " "
347    [2]=>
348    int(5)
349  }
350  [41]=>
351  string(1) "="
352  [42]=>
353  array(3) {
354    [0]=>
355    int(%d)
356    [1]=>
357    string(1) " "
358    [2]=>
359    int(5)
360  }
361  [43]=>
362  array(3) {
363    [0]=>
364    int(%d)
365    [1]=>
366    string(8) "(string)"
367    [2]=>
368    int(5)
369  }
370  [44]=>
371  array(3) {
372    [0]=>
373    int(%d)
374    [1]=>
375    string(2) "$a"
376    [2]=>
377    int(5)
378  }
379  [45]=>
380  string(1) "."
381  [46]=>
382  array(3) {
383    [0]=>
384    int(%d)
385    [1]=>
386    string(8) "(string)"
387    [2]=>
388    int(5)
389  }
390  [47]=>
391  array(3) {
392    [0]=>
393    int(%d)
394    [1]=>
395    string(2) "$b"
396    [2]=>
397    int(5)
398  }
399  [48]=>
400  string(1) ";"
401  [49]=>
402  array(3) {
403    [0]=>
404    int(%d)
405    [1]=>
406    string(1) "
407"
408    [2]=>
409    int(5)
410  }
411  [50]=>
412  array(3) {
413    [0]=>
414    int(%d)
415    [1]=>
416    string(2) "if"
417    [2]=>
418    int(6)
419  }
420  [51]=>
421  string(1) "("
422  [52]=>
423  array(3) {
424    [0]=>
425    int(%d)
426    [1]=>
427    string(6) "(bool)"
428    [2]=>
429    int(6)
430  }
431  [53]=>
432  array(3) {
433    [0]=>
434    int(%d)
435    [1]=>
436    string(2) "$a"
437    [2]=>
438    int(6)
439  }
440  [54]=>
441  string(1) ")"
442  [55]=>
443  array(3) {
444    [0]=>
445    int(%d)
446    [1]=>
447    string(1) " "
448    [2]=>
449    int(6)
450  }
451  [56]=>
452  array(3) {
453    [0]=>
454    int(%d)
455    [1]=>
456    string(4) "echo"
457    [2]=>
458    int(6)
459  }
460  [57]=>
461  array(3) {
462    [0]=>
463    int(%d)
464    [1]=>
465    string(1) " "
466    [2]=>
467    int(6)
468  }
469  [58]=>
470  array(3) {
471    [0]=>
472    int(%d)
473    [1]=>
474    string(6) ""true""
475    [2]=>
476    int(6)
477  }
478  [59]=>
479  string(1) ";"
480  [60]=>
481  array(3) {
482    [0]=>
483    int(%d)
484    [1]=>
485    string(1) "
486"
487    [2]=>
488    int(6)
489  }
490  [61]=>
491  array(3) {
492    [0]=>
493    int(%d)
494    [1]=>
495    string(2) "if"
496    [2]=>
497    int(7)
498  }
499  [62]=>
500  string(1) "("
501  [63]=>
502  string(1) "!"
503  [64]=>
504  array(3) {
505    [0]=>
506    int(%d)
507    [1]=>
508    string(9) "(boolean)"
509    [2]=>
510    int(7)
511  }
512  [65]=>
513  array(3) {
514    [0]=>
515    int(%d)
516    [1]=>
517    string(2) "$b"
518    [2]=>
519    int(7)
520  }
521  [66]=>
522  string(1) ")"
523  [67]=>
524  array(3) {
525    [0]=>
526    int(%d)
527    [1]=>
528    string(1) " "
529    [2]=>
530    int(7)
531  }
532  [68]=>
533  array(3) {
534    [0]=>
535    int(%d)
536    [1]=>
537    string(4) "echo"
538    [2]=>
539    int(7)
540  }
541  [69]=>
542  array(3) {
543    [0]=>
544    int(%d)
545    [1]=>
546    string(1) " "
547    [2]=>
548    int(7)
549  }
550  [70]=>
551  array(3) {
552    [0]=>
553    int(%d)
554    [1]=>
555    string(7) ""false""
556    [2]=>
557    int(7)
558  }
559  [71]=>
560  string(1) ";"
561  [72]=>
562  array(3) {
563    [0]=>
564    int(%d)
565    [1]=>
566    string(1) "
567"
568    [2]=>
569    int(7)
570  }
571  [73]=>
572  array(3) {
573    [0]=>
574    int(%d)
575    [1]=>
576    string(2) "$c"
577    [2]=>
578    int(8)
579  }
580  [74]=>
581  array(3) {
582    [0]=>
583    int(%d)
584    [1]=>
585    string(1) " "
586    [2]=>
587    int(8)
588  }
589  [75]=>
590  string(1) "="
591  [76]=>
592  array(3) {
593    [0]=>
594    int(%d)
595    [1]=>
596    string(1) " "
597    [2]=>
598    int(8)
599  }
600  [77]=>
601  array(3) {
602    [0]=>
603    int(%d)
604    [1]=>
605    string(2) "$c"
606    [2]=>
607    int(8)
608  }
609  [78]=>
610  array(3) {
611    [0]=>
612    int(%d)
613    [1]=>
614    string(1) " "
615    [2]=>
616    int(8)
617  }
618  [79]=>
619  string(1) "+"
620  [80]=>
621  array(3) {
622    [0]=>
623    int(%d)
624    [1]=>
625    string(1) " "
626    [2]=>
627    int(8)
628  }
629  [81]=>
630  array(3) {
631    [0]=>
632    int(%d)
633    [1]=>
634    string(9) "(integer)"
635    [2]=>
636    int(8)
637  }
638  [82]=>
639  array(3) {
640    [0]=>
641    int(%d)
642    [1]=>
643    string(1) " "
644    [2]=>
645    int(8)
646  }
647  [83]=>
648  array(3) {
649    [0]=>
650    int(%d)
651    [1]=>
652    string(7) "123.4e2"
653    [2]=>
654    int(8)
655  }
656  [84]=>
657  string(1) ";"
658  [85]=>
659  array(3) {
660    [0]=>
661    int(%d)
662    [1]=>
663    string(1) "
664"
665    [2]=>
666    int(8)
667  }
668  [86]=>
669  array(3) {
670    [0]=>
671    int(%d)
672    [1]=>
673    string(2) "$d"
674    [2]=>
675    int(9)
676  }
677  [87]=>
678  array(3) {
679    [0]=>
680    int(%d)
681    [1]=>
682    string(1) " "
683    [2]=>
684    int(9)
685  }
686  [88]=>
687  string(1) "="
688  [89]=>
689  array(3) {
690    [0]=>
691    int(%d)
692    [1]=>
693    string(1) " "
694    [2]=>
695    int(9)
696  }
697  [90]=>
698  array(3) {
699    [0]=>
700    int(%d)
701    [1]=>
702    string(2) "$c"
703    [2]=>
704    int(9)
705  }
706  [91]=>
707  array(3) {
708    [0]=>
709    int(%d)
710    [1]=>
711    string(1) " "
712    [2]=>
713    int(9)
714  }
715  [92]=>
716  string(1) "-"
717  [93]=>
718  array(3) {
719    [0]=>
720    int(%d)
721    [1]=>
722    string(1) " "
723    [2]=>
724    int(9)
725  }
726  [94]=>
727  array(3) {
728    [0]=>
729    int(%d)
730    [1]=>
731    string(6) "(real)"
732    [2]=>
733    int(9)
734  }
735  [95]=>
736  array(3) {
737    [0]=>
738    int(%d)
739    [1]=>
740    string(1) " "
741    [2]=>
742    int(9)
743  }
744  [96]=>
745  array(3) {
746    [0]=>
747    int(%d)
748    [1]=>
749    string(2) "12"
750    [2]=>
751    int(9)
752  }
753  [97]=>
754  string(1) ";"
755  [98]=>
756  array(3) {
757    [0]=>
758    int(%d)
759    [1]=>
760    string(1) "
761"
762    [2]=>
763    int(9)
764  }
765  [99]=>
766  array(3) {
767    [0]=>
768    int(%d)
769    [1]=>
770    string(2) "$b"
771    [2]=>
772    int(10)
773  }
774  [100]=>
775  array(3) {
776    [0]=>
777    int(%d)
778    [1]=>
779    string(1) " "
780    [2]=>
781    int(10)
782  }
783  [101]=>
784  string(1) "="
785  [102]=>
786  array(3) {
787    [0]=>
788    int(%d)
789    [1]=>
790    string(1) " "
791    [2]=>
792    int(10)
793  }
794  [103]=>
795  array(3) {
796    [0]=>
797    int(%d)
798    [1]=>
799    string(7) "(unset)"
800    [2]=>
801    int(10)
802  }
803  [104]=>
804  array(3) {
805    [0]=>
806    int(%d)
807    [1]=>
808    string(2) "$a"
809    [2]=>
810    int(10)
811  }
812  [105]=>
813  string(1) ";"
814  [106]=>
815  array(3) {
816    [0]=>
817    int(%d)
818    [1]=>
819    string(1) "
820"
821    [2]=>
822    int(10)
823  }
824  [107]=>
825  array(3) {
826    [0]=>
827    int(%d)
828    [1]=>
829    string(2) "?>"
830    [2]=>
831    int(11)
832  }
833}
834Done
835