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