1--TEST--
2Test token_get_all() function : usage variations - invalid token values
3--EXTENSIONS--
4tokenizer
5--FILE--
6<?php
7/*
8 * Testing token_get_all() with 'source' string containing invalid/unknown token value
9 *  unknown tokens - T_UNKNOWN(307)
10*/
11
12echo "*** Testing token_get_all() : with invalid/unknown tokens ***\n";
13
14// with valid php tags and invalid tokens
15echo "-- with valid PHP tags & invlid tokens --\n";
16$source = '<?php
17struct myStruct {
18  variable $a;
19  method() { display $a; }
20}
21?>';
22var_dump( token_get_all($source));
23
24// with invalid open tag for testing entire source to be unknown token
25echo "-- with invlalid PHP open tag & valid tokens --\n";
26$source = '<pli
27echo "hello world"; ?>';
28var_dump( token_get_all($source));
29
30// with invalid PHP tags and invalid tokens
31echo "-- with invalid PHP tags and tokens --\n";
32$source = '<PDP display  $a; <';
33var_dump( token_get_all($source));
34
35echo "Done"
36?>
37--EXPECTF--
38*** Testing token_get_all() : with invalid/unknown tokens ***
39-- with valid PHP tags & invlid tokens --
40array(28) {
41  [0]=>
42  array(3) {
43    [0]=>
44    int(%d)
45    [1]=>
46    string(6) "<?php
47"
48    [2]=>
49    int(1)
50  }
51  [1]=>
52  array(3) {
53    [0]=>
54    int(%d)
55    [1]=>
56    string(6) "struct"
57    [2]=>
58    int(2)
59  }
60  [2]=>
61  array(3) {
62    [0]=>
63    int(%d)
64    [1]=>
65    string(1) " "
66    [2]=>
67    int(2)
68  }
69  [3]=>
70  array(3) {
71    [0]=>
72    int(%d)
73    [1]=>
74    string(8) "myStruct"
75    [2]=>
76    int(2)
77  }
78  [4]=>
79  array(3) {
80    [0]=>
81    int(%d)
82    [1]=>
83    string(1) " "
84    [2]=>
85    int(2)
86  }
87  [5]=>
88  string(1) "{"
89  [6]=>
90  array(3) {
91    [0]=>
92    int(%d)
93    [1]=>
94    string(3) "
95  "
96    [2]=>
97    int(2)
98  }
99  [7]=>
100  array(3) {
101    [0]=>
102    int(%d)
103    [1]=>
104    string(8) "variable"
105    [2]=>
106    int(%d)
107  }
108  [8]=>
109  array(3) {
110    [0]=>
111    int(%d)
112    [1]=>
113    string(1) " "
114    [2]=>
115    int(%d)
116  }
117  [9]=>
118  array(3) {
119    [0]=>
120    int(%d)
121    [1]=>
122    string(2) "$a"
123    [2]=>
124    int(%d)
125  }
126  [10]=>
127  string(1) ";"
128  [11]=>
129  array(3) {
130    [0]=>
131    int(%d)
132    [1]=>
133    string(3) "
134  "
135    [2]=>
136    int(%d)
137  }
138  [12]=>
139  array(3) {
140    [0]=>
141    int(%d)
142    [1]=>
143    string(6) "method"
144    [2]=>
145    int(4)
146  }
147  [13]=>
148  string(1) "("
149  [14]=>
150  string(1) ")"
151  [15]=>
152  array(3) {
153    [0]=>
154    int(%d)
155    [1]=>
156    string(1) " "
157    [2]=>
158    int(4)
159  }
160  [16]=>
161  string(1) "{"
162  [17]=>
163  array(3) {
164    [0]=>
165    int(%d)
166    [1]=>
167    string(1) " "
168    [2]=>
169    int(4)
170  }
171  [18]=>
172  array(3) {
173    [0]=>
174    int(%d)
175    [1]=>
176    string(7) "display"
177    [2]=>
178    int(4)
179  }
180  [19]=>
181  array(3) {
182    [0]=>
183    int(%d)
184    [1]=>
185    string(1) " "
186    [2]=>
187    int(4)
188  }
189  [20]=>
190  array(3) {
191    [0]=>
192    int(%d)
193    [1]=>
194    string(2) "$a"
195    [2]=>
196    int(4)
197  }
198  [21]=>
199  string(1) ";"
200  [22]=>
201  array(3) {
202    [0]=>
203    int(%d)
204    [1]=>
205    string(1) " "
206    [2]=>
207    int(4)
208  }
209  [23]=>
210  string(1) "}"
211  [24]=>
212  array(3) {
213    [0]=>
214    int(%d)
215    [1]=>
216    string(1) "
217"
218    [2]=>
219    int(4)
220  }
221  [25]=>
222  string(1) "}"
223  [26]=>
224  array(3) {
225    [0]=>
226    int(%d)
227    [1]=>
228    string(1) "
229"
230    [2]=>
231    int(5)
232  }
233  [27]=>
234  array(3) {
235    [0]=>
236    int(%d)
237    [1]=>
238    string(2) "?>"
239    [2]=>
240    int(6)
241  }
242}
243-- with invlalid PHP open tag & valid tokens --
244array(1) {
245  [0]=>
246  array(3) {
247    [0]=>
248    int(%d)
249    [1]=>
250    string(27) "<pli
251echo "hello world"; ?>"
252    [2]=>
253    int(1)
254  }
255}
256-- with invalid PHP tags and tokens --
257array(1) {
258  [0]=>
259  array(3) {
260    [0]=>
261    int(%d)
262    [1]=>
263    string(19) "<PDP display  $a; <"
264    [2]=>
265    int(1)
266  }
267}
268Done
269