1--TEST-- 2Test token_get_all() function : usage variations - with logical operators 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 logical operators to test them for tokens 14 * and - T_AND_LOGICAL_AND(265), 15 * or - T_LOGICAL_OR(263), 16 * xor - T_LOGICAL_XOR(264), 17 * && - T_BOOLEAN_AND(279), 18 * || - T_BOOLEAN_OR(278) 19*/ 20 21echo "*** Testing token_get_all() : 'source' string with different logical operators ***\n"; 22 23// logical operators : 'and', 'or', 'xor', '&&', '||' 24$source = array ( 25 '<?php $a = 1 and 024; ?>', 26 '<?php $b = $b or 0X1E; ?>', 27 '<?php $c = $a xor $b; ?>', 28 '<?php $a = $b && 2; ?>', 29 '<?php $b = $b || 1; ?>' 30); 31for($count = 0; $count < count($source); $count++) { 32 echo "-- Iteration ".($count + 1)." --\n"; 33 var_dump( token_get_all($source[$count])); 34} 35 36echo "Done" 37?> 38--EXPECTF-- 39*** Testing token_get_all() : 'source' string with different logical operators *** 40-- Iteration 1 -- 41array(13) { 42 [0]=> 43 array(3) { 44 [0]=> 45 int(%d) 46 [1]=> 47 string(6) "<?php " 48 [2]=> 49 int(1) 50 } 51 [1]=> 52 array(3) { 53 [0]=> 54 int(%d) 55 [1]=> 56 string(2) "$a" 57 [2]=> 58 int(1) 59 } 60 [2]=> 61 array(3) { 62 [0]=> 63 int(%d) 64 [1]=> 65 string(1) " " 66 [2]=> 67 int(1) 68 } 69 [3]=> 70 string(1) "=" 71 [4]=> 72 array(3) { 73 [0]=> 74 int(%d) 75 [1]=> 76 string(1) " " 77 [2]=> 78 int(1) 79 } 80 [5]=> 81 array(3) { 82 [0]=> 83 int(%d) 84 [1]=> 85 string(1) "1" 86 [2]=> 87 int(1) 88 } 89 [6]=> 90 array(3) { 91 [0]=> 92 int(%d) 93 [1]=> 94 string(1) " " 95 [2]=> 96 int(1) 97 } 98 [7]=> 99 array(3) { 100 [0]=> 101 int(%d) 102 [1]=> 103 string(3) "and" 104 [2]=> 105 int(1) 106 } 107 [8]=> 108 array(3) { 109 [0]=> 110 int(%d) 111 [1]=> 112 string(1) " " 113 [2]=> 114 int(1) 115 } 116 [9]=> 117 array(3) { 118 [0]=> 119 int(%d) 120 [1]=> 121 string(3) "024" 122 [2]=> 123 int(1) 124 } 125 [10]=> 126 string(1) ";" 127 [11]=> 128 array(3) { 129 [0]=> 130 int(%d) 131 [1]=> 132 string(1) " " 133 [2]=> 134 int(1) 135 } 136 [12]=> 137 array(3) { 138 [0]=> 139 int(%d) 140 [1]=> 141 string(2) "?>" 142 [2]=> 143 int(1) 144 } 145} 146-- Iteration 2 -- 147array(13) { 148 [0]=> 149 array(3) { 150 [0]=> 151 int(%d) 152 [1]=> 153 string(6) "<?php " 154 [2]=> 155 int(1) 156 } 157 [1]=> 158 array(3) { 159 [0]=> 160 int(%d) 161 [1]=> 162 string(2) "$b" 163 [2]=> 164 int(1) 165 } 166 [2]=> 167 array(3) { 168 [0]=> 169 int(%d) 170 [1]=> 171 string(1) " " 172 [2]=> 173 int(1) 174 } 175 [3]=> 176 string(1) "=" 177 [4]=> 178 array(3) { 179 [0]=> 180 int(%d) 181 [1]=> 182 string(1) " " 183 [2]=> 184 int(1) 185 } 186 [5]=> 187 array(3) { 188 [0]=> 189 int(%d) 190 [1]=> 191 string(2) "$b" 192 [2]=> 193 int(1) 194 } 195 [6]=> 196 array(3) { 197 [0]=> 198 int(%d) 199 [1]=> 200 string(1) " " 201 [2]=> 202 int(1) 203 } 204 [7]=> 205 array(3) { 206 [0]=> 207 int(%d) 208 [1]=> 209 string(2) "or" 210 [2]=> 211 int(1) 212 } 213 [8]=> 214 array(3) { 215 [0]=> 216 int(%d) 217 [1]=> 218 string(1) " " 219 [2]=> 220 int(1) 221 } 222 [9]=> 223 array(3) { 224 [0]=> 225 int(%d) 226 [1]=> 227 string(4) "0X1E" 228 [2]=> 229 int(1) 230 } 231 [10]=> 232 string(1) ";" 233 [11]=> 234 array(3) { 235 [0]=> 236 int(%d) 237 [1]=> 238 string(1) " " 239 [2]=> 240 int(1) 241 } 242 [12]=> 243 array(3) { 244 [0]=> 245 int(%d) 246 [1]=> 247 string(2) "?>" 248 [2]=> 249 int(1) 250 } 251} 252-- Iteration 3 -- 253array(13) { 254 [0]=> 255 array(3) { 256 [0]=> 257 int(%d) 258 [1]=> 259 string(6) "<?php " 260 [2]=> 261 int(1) 262 } 263 [1]=> 264 array(3) { 265 [0]=> 266 int(%d) 267 [1]=> 268 string(2) "$c" 269 [2]=> 270 int(1) 271 } 272 [2]=> 273 array(3) { 274 [0]=> 275 int(%d) 276 [1]=> 277 string(1) " " 278 [2]=> 279 int(1) 280 } 281 [3]=> 282 string(1) "=" 283 [4]=> 284 array(3) { 285 [0]=> 286 int(%d) 287 [1]=> 288 string(1) " " 289 [2]=> 290 int(1) 291 } 292 [5]=> 293 array(3) { 294 [0]=> 295 int(%d) 296 [1]=> 297 string(2) "$a" 298 [2]=> 299 int(1) 300 } 301 [6]=> 302 array(3) { 303 [0]=> 304 int(%d) 305 [1]=> 306 string(1) " " 307 [2]=> 308 int(1) 309 } 310 [7]=> 311 array(3) { 312 [0]=> 313 int(%d) 314 [1]=> 315 string(3) "xor" 316 [2]=> 317 int(1) 318 } 319 [8]=> 320 array(3) { 321 [0]=> 322 int(%d) 323 [1]=> 324 string(1) " " 325 [2]=> 326 int(1) 327 } 328 [9]=> 329 array(3) { 330 [0]=> 331 int(%d) 332 [1]=> 333 string(2) "$b" 334 [2]=> 335 int(1) 336 } 337 [10]=> 338 string(1) ";" 339 [11]=> 340 array(3) { 341 [0]=> 342 int(%d) 343 [1]=> 344 string(1) " " 345 [2]=> 346 int(1) 347 } 348 [12]=> 349 array(3) { 350 [0]=> 351 int(%d) 352 [1]=> 353 string(2) "?>" 354 [2]=> 355 int(1) 356 } 357} 358-- Iteration 4 -- 359array(13) { 360 [0]=> 361 array(3) { 362 [0]=> 363 int(%d) 364 [1]=> 365 string(6) "<?php " 366 [2]=> 367 int(1) 368 } 369 [1]=> 370 array(3) { 371 [0]=> 372 int(%d) 373 [1]=> 374 string(2) "$a" 375 [2]=> 376 int(1) 377 } 378 [2]=> 379 array(3) { 380 [0]=> 381 int(%d) 382 [1]=> 383 string(1) " " 384 [2]=> 385 int(1) 386 } 387 [3]=> 388 string(1) "=" 389 [4]=> 390 array(3) { 391 [0]=> 392 int(%d) 393 [1]=> 394 string(1) " " 395 [2]=> 396 int(1) 397 } 398 [5]=> 399 array(3) { 400 [0]=> 401 int(%d) 402 [1]=> 403 string(2) "$b" 404 [2]=> 405 int(1) 406 } 407 [6]=> 408 array(3) { 409 [0]=> 410 int(%d) 411 [1]=> 412 string(1) " " 413 [2]=> 414 int(1) 415 } 416 [7]=> 417 array(3) { 418 [0]=> 419 int(%d) 420 [1]=> 421 string(2) "&&" 422 [2]=> 423 int(1) 424 } 425 [8]=> 426 array(3) { 427 [0]=> 428 int(%d) 429 [1]=> 430 string(1) " " 431 [2]=> 432 int(1) 433 } 434 [9]=> 435 array(3) { 436 [0]=> 437 int(%d) 438 [1]=> 439 string(1) "2" 440 [2]=> 441 int(1) 442 } 443 [10]=> 444 string(1) ";" 445 [11]=> 446 array(3) { 447 [0]=> 448 int(%d) 449 [1]=> 450 string(1) " " 451 [2]=> 452 int(1) 453 } 454 [12]=> 455 array(3) { 456 [0]=> 457 int(%d) 458 [1]=> 459 string(2) "?>" 460 [2]=> 461 int(1) 462 } 463} 464-- Iteration 5 -- 465array(13) { 466 [0]=> 467 array(3) { 468 [0]=> 469 int(%d) 470 [1]=> 471 string(6) "<?php " 472 [2]=> 473 int(1) 474 } 475 [1]=> 476 array(3) { 477 [0]=> 478 int(%d) 479 [1]=> 480 string(2) "$b" 481 [2]=> 482 int(1) 483 } 484 [2]=> 485 array(3) { 486 [0]=> 487 int(%d) 488 [1]=> 489 string(1) " " 490 [2]=> 491 int(1) 492 } 493 [3]=> 494 string(1) "=" 495 [4]=> 496 array(3) { 497 [0]=> 498 int(%d) 499 [1]=> 500 string(1) " " 501 [2]=> 502 int(1) 503 } 504 [5]=> 505 array(3) { 506 [0]=> 507 int(%d) 508 [1]=> 509 string(2) "$b" 510 [2]=> 511 int(1) 512 } 513 [6]=> 514 array(3) { 515 [0]=> 516 int(%d) 517 [1]=> 518 string(1) " " 519 [2]=> 520 int(1) 521 } 522 [7]=> 523 array(3) { 524 [0]=> 525 int(%d) 526 [1]=> 527 string(2) "||" 528 [2]=> 529 int(1) 530 } 531 [8]=> 532 array(3) { 533 [0]=> 534 int(%d) 535 [1]=> 536 string(1) " " 537 [2]=> 538 int(1) 539 } 540 [9]=> 541 array(3) { 542 [0]=> 543 int(%d) 544 [1]=> 545 string(1) "1" 546 [2]=> 547 int(1) 548 } 549 [10]=> 550 string(1) ";" 551 [11]=> 552 array(3) { 553 [0]=> 554 int(%d) 555 [1]=> 556 string(1) " " 557 [2]=> 558 int(1) 559 } 560 [12]=> 561 array(3) { 562 [0]=> 563 int(%d) 564 [1]=> 565 string(2) "?>" 566 [2]=> 567 int(1) 568 } 569} 570Done 571