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