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