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