1--TEST-- 2Test token_get_all() function : usage variations - with different types of comments 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 * Passing 'source' argument with different style of comments 14 */ 15// '//', '/* */', '#' - T_COMMENT(365) 16// '/** */' - T_DOC_COMMENT(366) 17 18 19echo "*** Testing token_get_all() : 'source' string with different comments ***\n"; 20 21// types of comments: '//', '/* */', '#' & /** */ 22 23$source = '<?php 24/** Performing addition operation on given values : 25 * a, b 26 */ 27 28// int value 29$a = 10; 30$b = 20; 31$c = true; // bool value 32 33/* 34 * Performing operation on $a,$b 35 * display result 36 */ 37$c = $a + $b; 38var_dump($c); # expected: int(30) 39 40# end of program 41?>'; 42var_dump( token_get_all($source)); 43 44echo "Done" 45?> 46--EXPECTF-- 47*** Testing token_get_all() : 'source' string with different comments *** 48array(51) { 49 [0]=> 50 array(3) { 51 [0]=> 52 int(%d) 53 [1]=> 54 string(6) "<?php " 55 [2]=> 56 int(1) 57 } 58 [1]=> 59 array(3) { 60 [0]=> 61 int(%d) 62 [1]=> 63 string(1) " 64" 65 [2]=> 66 int(1) 67 } 68 [2]=> 69 array(3) { 70 [0]=> 71 int(%d) 72 [1]=> 73 string(65) "/** Performing addition operation on given values : 74 * a, b 75 */" 76 [2]=> 77 int(2) 78 } 79 [3]=> 80 array(3) { 81 [0]=> 82 int(%d) 83 [1]=> 84 string(2) " 85 86" 87 [2]=> 88 int(4) 89 } 90 [4]=> 91 array(3) { 92 [0]=> 93 int(%d) 94 [1]=> 95 string(13) "// int value 96" 97 [2]=> 98 int(6) 99 } 100 [5]=> 101 array(3) { 102 [0]=> 103 int(%d) 104 [1]=> 105 string(2) "$a" 106 [2]=> 107 int(7) 108 } 109 [6]=> 110 array(3) { 111 [0]=> 112 int(%d) 113 [1]=> 114 string(1) " " 115 [2]=> 116 int(7) 117 } 118 [7]=> 119 string(1) "=" 120 [8]=> 121 array(3) { 122 [0]=> 123 int(%d) 124 [1]=> 125 string(1) " " 126 [2]=> 127 int(7) 128 } 129 [9]=> 130 array(3) { 131 [0]=> 132 int(%d) 133 [1]=> 134 string(2) "10" 135 [2]=> 136 int(7) 137 } 138 [10]=> 139 string(1) ";" 140 [11]=> 141 array(3) { 142 [0]=> 143 int(%d) 144 [1]=> 145 string(1) " 146" 147 [2]=> 148 int(7) 149 } 150 [12]=> 151 array(3) { 152 [0]=> 153 int(%d) 154 [1]=> 155 string(2) "$b" 156 [2]=> 157 int(8) 158 } 159 [13]=> 160 array(3) { 161 [0]=> 162 int(%d) 163 [1]=> 164 string(1) " " 165 [2]=> 166 int(8) 167 } 168 [14]=> 169 string(1) "=" 170 [15]=> 171 array(3) { 172 [0]=> 173 int(%d) 174 [1]=> 175 string(1) " " 176 [2]=> 177 int(8) 178 } 179 [16]=> 180 array(3) { 181 [0]=> 182 int(%d) 183 [1]=> 184 string(2) "20" 185 [2]=> 186 int(8) 187 } 188 [17]=> 189 string(1) ";" 190 [18]=> 191 array(3) { 192 [0]=> 193 int(%d) 194 [1]=> 195 string(1) " 196" 197 [2]=> 198 int(8) 199 } 200 [19]=> 201 array(3) { 202 [0]=> 203 int(%d) 204 [1]=> 205 string(2) "$c" 206 [2]=> 207 int(9) 208 } 209 [20]=> 210 array(3) { 211 [0]=> 212 int(%d) 213 [1]=> 214 string(1) " " 215 [2]=> 216 int(9) 217 } 218 [21]=> 219 string(1) "=" 220 [22]=> 221 array(3) { 222 [0]=> 223 int(%d) 224 [1]=> 225 string(1) " " 226 [2]=> 227 int(9) 228 } 229 [23]=> 230 array(3) { 231 [0]=> 232 int(%d) 233 [1]=> 234 string(4) "true" 235 [2]=> 236 int(9) 237 } 238 [24]=> 239 string(1) ";" 240 [25]=> 241 array(3) { 242 [0]=> 243 int(%d) 244 [1]=> 245 string(1) " " 246 [2]=> 247 int(9) 248 } 249 [26]=> 250 array(3) { 251 [0]=> 252 int(%d) 253 [1]=> 254 string(14) "// bool value 255" 256 [2]=> 257 int(9) 258 } 259 [27]=> 260 array(3) { 261 [0]=> 262 int(%d) 263 [1]=> 264 string(1) " 265" 266 [2]=> 267 int(10) 268 } 269 [28]=> 270 array(3) { 271 [0]=> 272 int(%d) 273 [1]=> 274 string(59) "/* 275 * Performing operation on $a,$b 276 * display result 277 */" 278 [2]=> 279 int(11) 280 } 281 [29]=> 282 array(3) { 283 [0]=> 284 int(%d) 285 [1]=> 286 string(1) " 287" 288 [2]=> 289 int(14) 290 } 291 [30]=> 292 array(3) { 293 [0]=> 294 int(%d) 295 [1]=> 296 string(2) "$c" 297 [2]=> 298 int(15) 299 } 300 [31]=> 301 array(3) { 302 [0]=> 303 int(%d) 304 [1]=> 305 string(1) " " 306 [2]=> 307 int(15) 308 } 309 [32]=> 310 string(1) "=" 311 [33]=> 312 array(3) { 313 [0]=> 314 int(%d) 315 [1]=> 316 string(1) " " 317 [2]=> 318 int(15) 319 } 320 [34]=> 321 array(3) { 322 [0]=> 323 int(%d) 324 [1]=> 325 string(2) "$a" 326 [2]=> 327 int(15) 328 } 329 [35]=> 330 array(3) { 331 [0]=> 332 int(%d) 333 [1]=> 334 string(1) " " 335 [2]=> 336 int(15) 337 } 338 [36]=> 339 string(1) "+" 340 [37]=> 341 array(3) { 342 [0]=> 343 int(%d) 344 [1]=> 345 string(1) " " 346 [2]=> 347 int(15) 348 } 349 [38]=> 350 array(3) { 351 [0]=> 352 int(%d) 353 [1]=> 354 string(2) "$b" 355 [2]=> 356 int(15) 357 } 358 [39]=> 359 string(1) ";" 360 [40]=> 361 array(3) { 362 [0]=> 363 int(%d) 364 [1]=> 365 string(1) " 366" 367 [2]=> 368 int(15) 369 } 370 [41]=> 371 array(3) { 372 [0]=> 373 int(%d) 374 [1]=> 375 string(8) "var_dump" 376 [2]=> 377 int(16) 378 } 379 [42]=> 380 string(1) "(" 381 [43]=> 382 array(3) { 383 [0]=> 384 int(%d) 385 [1]=> 386 string(2) "$c" 387 [2]=> 388 int(16) 389 } 390 [44]=> 391 string(1) ")" 392 [45]=> 393 string(1) ";" 394 [46]=> 395 array(3) { 396 [0]=> 397 int(%d) 398 [1]=> 399 string(1) " " 400 [2]=> 401 int(16) 402 } 403 [47]=> 404 array(3) { 405 [0]=> 406 int(%d) 407 [1]=> 408 string(20) "# expected: int(%d) 409" 410 [2]=> 411 int(16) 412 } 413 [48]=> 414 array(3) { 415 [0]=> 416 int(%d) 417 [1]=> 418 string(1) " 419" 420 [2]=> 421 int(17) 422 } 423 [49]=> 424 array(3) { 425 [0]=> 426 int(%d) 427 [1]=> 428 string(17) "# end of program 429" 430 [2]=> 431 int(18) 432 } 433 [50]=> 434 array(3) { 435 [0]=> 436 int(%d) 437 [1]=> 438 string(2) "?>" 439 [2]=> 440 int(19) 441 } 442} 443Done 444