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