1--TEST--
2Test token_get_all() function : usage variations - with logical operators
3--EXTENSIONS--
4tokenizer
5--FILE--
6<?php
7/*
8 * Passing 'source' argument with different logical operators to test them for tokens
9 *   and - T_AND_LOGICAL_AND(265),
10 *   or - T_LOGICAL_OR(263),
11 *   xor - T_LOGICAL_XOR(264),
12 *   && - T_BOOLEAN_AND(279),
13 *   || - T_BOOLEAN_OR(278)
14*/
15
16echo "*** Testing token_get_all() : 'source' string with different logical operators ***\n";
17
18// logical operators : 'and', 'or', 'xor', '&&', '||'
19$source = array (
20  '<?php $a = 1 and 024; ?>',
21  '<?php $b = $b or 0X1E; ?>',
22  '<?php $c = $a xor $b; ?>',
23  '<?php $a = $b && 2; ?>',
24  '<?php $b = $b || 1; ?>'
25);
26for($count = 0; $count < count($source); $count++) {
27  echo "-- Iteration ".($count + 1)." --\n";
28  var_dump( token_get_all($source[$count]));
29}
30
31echo "Done"
32?>
33--EXPECTF--
34*** Testing token_get_all() : 'source' string with different logical operators ***
35-- Iteration 1 --
36array(13) {
37  [0]=>
38  array(3) {
39    [0]=>
40    int(%d)
41    [1]=>
42    string(6) "<?php "
43    [2]=>
44    int(1)
45  }
46  [1]=>
47  array(3) {
48    [0]=>
49    int(%d)
50    [1]=>
51    string(2) "$a"
52    [2]=>
53    int(1)
54  }
55  [2]=>
56  array(3) {
57    [0]=>
58    int(%d)
59    [1]=>
60    string(1) " "
61    [2]=>
62    int(1)
63  }
64  [3]=>
65  string(1) "="
66  [4]=>
67  array(3) {
68    [0]=>
69    int(%d)
70    [1]=>
71    string(1) " "
72    [2]=>
73    int(1)
74  }
75  [5]=>
76  array(3) {
77    [0]=>
78    int(%d)
79    [1]=>
80    string(1) "1"
81    [2]=>
82    int(1)
83  }
84  [6]=>
85  array(3) {
86    [0]=>
87    int(%d)
88    [1]=>
89    string(1) " "
90    [2]=>
91    int(1)
92  }
93  [7]=>
94  array(3) {
95    [0]=>
96    int(%d)
97    [1]=>
98    string(3) "and"
99    [2]=>
100    int(1)
101  }
102  [8]=>
103  array(3) {
104    [0]=>
105    int(%d)
106    [1]=>
107    string(1) " "
108    [2]=>
109    int(1)
110  }
111  [9]=>
112  array(3) {
113    [0]=>
114    int(%d)
115    [1]=>
116    string(3) "024"
117    [2]=>
118    int(1)
119  }
120  [10]=>
121  string(1) ";"
122  [11]=>
123  array(3) {
124    [0]=>
125    int(%d)
126    [1]=>
127    string(1) " "
128    [2]=>
129    int(1)
130  }
131  [12]=>
132  array(3) {
133    [0]=>
134    int(%d)
135    [1]=>
136    string(2) "?>"
137    [2]=>
138    int(1)
139  }
140}
141-- Iteration 2 --
142array(13) {
143  [0]=>
144  array(3) {
145    [0]=>
146    int(%d)
147    [1]=>
148    string(6) "<?php "
149    [2]=>
150    int(1)
151  }
152  [1]=>
153  array(3) {
154    [0]=>
155    int(%d)
156    [1]=>
157    string(2) "$b"
158    [2]=>
159    int(1)
160  }
161  [2]=>
162  array(3) {
163    [0]=>
164    int(%d)
165    [1]=>
166    string(1) " "
167    [2]=>
168    int(1)
169  }
170  [3]=>
171  string(1) "="
172  [4]=>
173  array(3) {
174    [0]=>
175    int(%d)
176    [1]=>
177    string(1) " "
178    [2]=>
179    int(1)
180  }
181  [5]=>
182  array(3) {
183    [0]=>
184    int(%d)
185    [1]=>
186    string(2) "$b"
187    [2]=>
188    int(1)
189  }
190  [6]=>
191  array(3) {
192    [0]=>
193    int(%d)
194    [1]=>
195    string(1) " "
196    [2]=>
197    int(1)
198  }
199  [7]=>
200  array(3) {
201    [0]=>
202    int(%d)
203    [1]=>
204    string(2) "or"
205    [2]=>
206    int(1)
207  }
208  [8]=>
209  array(3) {
210    [0]=>
211    int(%d)
212    [1]=>
213    string(1) " "
214    [2]=>
215    int(1)
216  }
217  [9]=>
218  array(3) {
219    [0]=>
220    int(%d)
221    [1]=>
222    string(4) "0X1E"
223    [2]=>
224    int(1)
225  }
226  [10]=>
227  string(1) ";"
228  [11]=>
229  array(3) {
230    [0]=>
231    int(%d)
232    [1]=>
233    string(1) " "
234    [2]=>
235    int(1)
236  }
237  [12]=>
238  array(3) {
239    [0]=>
240    int(%d)
241    [1]=>
242    string(2) "?>"
243    [2]=>
244    int(1)
245  }
246}
247-- Iteration 3 --
248array(13) {
249  [0]=>
250  array(3) {
251    [0]=>
252    int(%d)
253    [1]=>
254    string(6) "<?php "
255    [2]=>
256    int(1)
257  }
258  [1]=>
259  array(3) {
260    [0]=>
261    int(%d)
262    [1]=>
263    string(2) "$c"
264    [2]=>
265    int(1)
266  }
267  [2]=>
268  array(3) {
269    [0]=>
270    int(%d)
271    [1]=>
272    string(1) " "
273    [2]=>
274    int(1)
275  }
276  [3]=>
277  string(1) "="
278  [4]=>
279  array(3) {
280    [0]=>
281    int(%d)
282    [1]=>
283    string(1) " "
284    [2]=>
285    int(1)
286  }
287  [5]=>
288  array(3) {
289    [0]=>
290    int(%d)
291    [1]=>
292    string(2) "$a"
293    [2]=>
294    int(1)
295  }
296  [6]=>
297  array(3) {
298    [0]=>
299    int(%d)
300    [1]=>
301    string(1) " "
302    [2]=>
303    int(1)
304  }
305  [7]=>
306  array(3) {
307    [0]=>
308    int(%d)
309    [1]=>
310    string(3) "xor"
311    [2]=>
312    int(1)
313  }
314  [8]=>
315  array(3) {
316    [0]=>
317    int(%d)
318    [1]=>
319    string(1) " "
320    [2]=>
321    int(1)
322  }
323  [9]=>
324  array(3) {
325    [0]=>
326    int(%d)
327    [1]=>
328    string(2) "$b"
329    [2]=>
330    int(1)
331  }
332  [10]=>
333  string(1) ";"
334  [11]=>
335  array(3) {
336    [0]=>
337    int(%d)
338    [1]=>
339    string(1) " "
340    [2]=>
341    int(1)
342  }
343  [12]=>
344  array(3) {
345    [0]=>
346    int(%d)
347    [1]=>
348    string(2) "?>"
349    [2]=>
350    int(1)
351  }
352}
353-- Iteration 4 --
354array(13) {
355  [0]=>
356  array(3) {
357    [0]=>
358    int(%d)
359    [1]=>
360    string(6) "<?php "
361    [2]=>
362    int(1)
363  }
364  [1]=>
365  array(3) {
366    [0]=>
367    int(%d)
368    [1]=>
369    string(2) "$a"
370    [2]=>
371    int(1)
372  }
373  [2]=>
374  array(3) {
375    [0]=>
376    int(%d)
377    [1]=>
378    string(1) " "
379    [2]=>
380    int(1)
381  }
382  [3]=>
383  string(1) "="
384  [4]=>
385  array(3) {
386    [0]=>
387    int(%d)
388    [1]=>
389    string(1) " "
390    [2]=>
391    int(1)
392  }
393  [5]=>
394  array(3) {
395    [0]=>
396    int(%d)
397    [1]=>
398    string(2) "$b"
399    [2]=>
400    int(1)
401  }
402  [6]=>
403  array(3) {
404    [0]=>
405    int(%d)
406    [1]=>
407    string(1) " "
408    [2]=>
409    int(1)
410  }
411  [7]=>
412  array(3) {
413    [0]=>
414    int(%d)
415    [1]=>
416    string(2) "&&"
417    [2]=>
418    int(1)
419  }
420  [8]=>
421  array(3) {
422    [0]=>
423    int(%d)
424    [1]=>
425    string(1) " "
426    [2]=>
427    int(1)
428  }
429  [9]=>
430  array(3) {
431    [0]=>
432    int(%d)
433    [1]=>
434    string(1) "2"
435    [2]=>
436    int(1)
437  }
438  [10]=>
439  string(1) ";"
440  [11]=>
441  array(3) {
442    [0]=>
443    int(%d)
444    [1]=>
445    string(1) " "
446    [2]=>
447    int(1)
448  }
449  [12]=>
450  array(3) {
451    [0]=>
452    int(%d)
453    [1]=>
454    string(2) "?>"
455    [2]=>
456    int(1)
457  }
458}
459-- Iteration 5 --
460array(13) {
461  [0]=>
462  array(3) {
463    [0]=>
464    int(%d)
465    [1]=>
466    string(6) "<?php "
467    [2]=>
468    int(1)
469  }
470  [1]=>
471  array(3) {
472    [0]=>
473    int(%d)
474    [1]=>
475    string(2) "$b"
476    [2]=>
477    int(1)
478  }
479  [2]=>
480  array(3) {
481    [0]=>
482    int(%d)
483    [1]=>
484    string(1) " "
485    [2]=>
486    int(1)
487  }
488  [3]=>
489  string(1) "="
490  [4]=>
491  array(3) {
492    [0]=>
493    int(%d)
494    [1]=>
495    string(1) " "
496    [2]=>
497    int(1)
498  }
499  [5]=>
500  array(3) {
501    [0]=>
502    int(%d)
503    [1]=>
504    string(2) "$b"
505    [2]=>
506    int(1)
507  }
508  [6]=>
509  array(3) {
510    [0]=>
511    int(%d)
512    [1]=>
513    string(1) " "
514    [2]=>
515    int(1)
516  }
517  [7]=>
518  array(3) {
519    [0]=>
520    int(%d)
521    [1]=>
522    string(2) "||"
523    [2]=>
524    int(1)
525  }
526  [8]=>
527  array(3) {
528    [0]=>
529    int(%d)
530    [1]=>
531    string(1) " "
532    [2]=>
533    int(1)
534  }
535  [9]=>
536  array(3) {
537    [0]=>
538    int(%d)
539    [1]=>
540    string(1) "1"
541    [2]=>
542    int(1)
543  }
544  [10]=>
545  string(1) ";"
546  [11]=>
547  array(3) {
548    [0]=>
549    int(%d)
550    [1]=>
551    string(1) " "
552    [2]=>
553    int(1)
554  }
555  [12]=>
556  array(3) {
557    [0]=>
558    int(%d)
559    [1]=>
560    string(2) "?>"
561    [2]=>
562    int(1)
563  }
564}
565Done
566