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