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