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