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