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