1--TEST-- 2Test token_get_all() function : usage variations - heredoc string for 'source' 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 heredoc 'source' string with all different types of token and heredoc string within 14 * <<<EOT - T_START_HEREDOC(371) 15 * EOT - T_END_HEREDOC(372) 16*/ 17 18echo "*** Testing token_get_all() : with heredoc source string ***\n"; 19 20$source = <<<EOT 21<?= 22 \$a = 2; 23 \$b = 1; 24 \$c = <<<EOS 25 This is to test 26 heredoc string 27EOS; 28 echo \$a + \$b; 29 function myFunction(\$a) 30 { 31 var_dump(\$a); 32 } 33 if(\$b < 10) { 34 \$b++; 35 } 36 else 37 \$b--; 38 while(\$a > 0) { 39 echo "*"; 40 \$a--; 41 } 42 myFunction(10); 43?> 44EOT; 45var_dump( token_get_all($source)); 46 47echo "Done" 48?> 49--EXPECTF-- 50*** Testing token_get_all() : with heredoc source string *** 51array(103) { 52 [0]=> 53 array(3) { 54 [0]=> 55 int(%d) 56 [1]=> 57 string(3) "<?=" 58 [2]=> 59 int(1) 60 } 61 [1]=> 62 array(3) { 63 [0]=> 64 int(%d) 65 [1]=> 66 string(4) " 67 " 68 [2]=> 69 int(1) 70 } 71 [2]=> 72 array(3) { 73 [0]=> 74 int(%d) 75 [1]=> 76 string(2) "$a" 77 [2]=> 78 int(2) 79 } 80 [3]=> 81 array(3) { 82 [0]=> 83 int(%d) 84 [1]=> 85 string(1) " " 86 [2]=> 87 int(2) 88 } 89 [4]=> 90 string(1) "=" 91 [5]=> 92 array(3) { 93 [0]=> 94 int(%d) 95 [1]=> 96 string(1) " " 97 [2]=> 98 int(2) 99 } 100 [6]=> 101 array(3) { 102 [0]=> 103 int(%d) 104 [1]=> 105 string(1) "2" 106 [2]=> 107 int(2) 108 } 109 [7]=> 110 string(1) ";" 111 [8]=> 112 array(3) { 113 [0]=> 114 int(%d) 115 [1]=> 116 string(3) " 117 " 118 [2]=> 119 int(2) 120 } 121 [9]=> 122 array(3) { 123 [0]=> 124 int(%d) 125 [1]=> 126 string(2) "$b" 127 [2]=> 128 int(%d) 129 } 130 [10]=> 131 array(3) { 132 [0]=> 133 int(%d) 134 [1]=> 135 string(1) " " 136 [2]=> 137 int(%d) 138 } 139 [11]=> 140 string(1) "=" 141 [12]=> 142 array(3) { 143 [0]=> 144 int(%d) 145 [1]=> 146 string(1) " " 147 [2]=> 148 int(%d) 149 } 150 [13]=> 151 array(3) { 152 [0]=> 153 int(%d) 154 [1]=> 155 string(1) "1" 156 [2]=> 157 int(%d) 158 } 159 [14]=> 160 string(1) ";" 161 [15]=> 162 array(3) { 163 [0]=> 164 int(%d) 165 [1]=> 166 string(3) " 167 " 168 [2]=> 169 int(%d) 170 } 171 [16]=> 172 array(3) { 173 [0]=> 174 int(%d) 175 [1]=> 176 string(2) "$c" 177 [2]=> 178 int(4) 179 } 180 [17]=> 181 array(3) { 182 [0]=> 183 int(%d) 184 [1]=> 185 string(1) " " 186 [2]=> 187 int(4) 188 } 189 [18]=> 190 string(1) "=" 191 [19]=> 192 array(3) { 193 [0]=> 194 int(%d) 195 [1]=> 196 string(1) " " 197 [2]=> 198 int(4) 199 } 200 [20]=> 201 array(3) { 202 [0]=> 203 int(%d) 204 [1]=> 205 string(7) "<<<EOS 206" 207 [2]=> 208 int(4) 209 } 210 [21]=> 211 array(3) { 212 [0]=> 213 int(%d) 214 [1]=> 215 string(36) " This is to test 216 heredoc string 217" 218 [2]=> 219 int(5) 220 } 221 [22]=> 222 array(3) { 223 [0]=> 224 int(%d) 225 [1]=> 226 string(3) "EOS" 227 [2]=> 228 int(7) 229 } 230 [23]=> 231 string(1) ";" 232 [24]=> 233 array(3) { 234 [0]=> 235 int(%d) 236 [1]=> 237 string(3) " 238 " 239 [2]=> 240 int(7) 241 } 242 [25]=> 243 array(3) { 244 [0]=> 245 int(%d) 246 [1]=> 247 string(4) "echo" 248 [2]=> 249 int(8) 250 } 251 [26]=> 252 array(3) { 253 [0]=> 254 int(%d) 255 [1]=> 256 string(1) " " 257 [2]=> 258 int(8) 259 } 260 [27]=> 261 array(3) { 262 [0]=> 263 int(%d) 264 [1]=> 265 string(2) "$a" 266 [2]=> 267 int(8) 268 } 269 [28]=> 270 array(3) { 271 [0]=> 272 int(%d) 273 [1]=> 274 string(1) " " 275 [2]=> 276 int(8) 277 } 278 [29]=> 279 string(1) "+" 280 [30]=> 281 array(3) { 282 [0]=> 283 int(%d) 284 [1]=> 285 string(1) " " 286 [2]=> 287 int(8) 288 } 289 [31]=> 290 array(3) { 291 [0]=> 292 int(%d) 293 [1]=> 294 string(2) "$b" 295 [2]=> 296 int(8) 297 } 298 [32]=> 299 string(1) ";" 300 [33]=> 301 array(3) { 302 [0]=> 303 int(%d) 304 [1]=> 305 string(3) " 306 " 307 [2]=> 308 int(8) 309 } 310 [34]=> 311 array(3) { 312 [0]=> 313 int(%d) 314 [1]=> 315 string(8) "function" 316 [2]=> 317 int(9) 318 } 319 [35]=> 320 array(3) { 321 [0]=> 322 int(%d) 323 [1]=> 324 string(1) " " 325 [2]=> 326 int(9) 327 } 328 [36]=> 329 array(3) { 330 [0]=> 331 int(%d) 332 [1]=> 333 string(10) "myFunction" 334 [2]=> 335 int(9) 336 } 337 [37]=> 338 string(1) "(" 339 [38]=> 340 array(3) { 341 [0]=> 342 int(%d) 343 [1]=> 344 string(2) "$a" 345 [2]=> 346 int(9) 347 } 348 [39]=> 349 string(1) ")" 350 [40]=> 351 array(3) { 352 [0]=> 353 int(%d) 354 [1]=> 355 string(3) " 356 " 357 [2]=> 358 int(9) 359 } 360 [41]=> 361 string(1) "{" 362 [42]=> 363 array(3) { 364 [0]=> 365 int(%d) 366 [1]=> 367 string(5) " 368 " 369 [2]=> 370 int(10) 371 } 372 [43]=> 373 array(3) { 374 [0]=> 375 int(%d) 376 [1]=> 377 string(8) "var_dump" 378 [2]=> 379 int(11) 380 } 381 [44]=> 382 string(1) "(" 383 [45]=> 384 array(3) { 385 [0]=> 386 int(%d) 387 [1]=> 388 string(2) "$a" 389 [2]=> 390 int(11) 391 } 392 [46]=> 393 string(1) ")" 394 [47]=> 395 string(1) ";" 396 [48]=> 397 array(3) { 398 [0]=> 399 int(%d) 400 [1]=> 401 string(3) " 402 " 403 [2]=> 404 int(11) 405 } 406 [49]=> 407 string(1) "}" 408 [50]=> 409 array(3) { 410 [0]=> 411 int(%d) 412 [1]=> 413 string(3) " 414 " 415 [2]=> 416 int(12) 417 } 418 [51]=> 419 array(3) { 420 [0]=> 421 int(%d) 422 [1]=> 423 string(2) "if" 424 [2]=> 425 int(13) 426 } 427 [52]=> 428 string(1) "(" 429 [53]=> 430 array(3) { 431 [0]=> 432 int(%d) 433 [1]=> 434 string(2) "$b" 435 [2]=> 436 int(13) 437 } 438 [54]=> 439 array(3) { 440 [0]=> 441 int(%d) 442 [1]=> 443 string(1) " " 444 [2]=> 445 int(13) 446 } 447 [55]=> 448 string(1) "<" 449 [56]=> 450 array(3) { 451 [0]=> 452 int(%d) 453 [1]=> 454 string(1) " " 455 [2]=> 456 int(13) 457 } 458 [57]=> 459 array(3) { 460 [0]=> 461 int(%d) 462 [1]=> 463 string(2) "10" 464 [2]=> 465 int(13) 466 } 467 [58]=> 468 string(1) ")" 469 [59]=> 470 array(3) { 471 [0]=> 472 int(%d) 473 [1]=> 474 string(1) " " 475 [2]=> 476 int(13) 477 } 478 [60]=> 479 string(1) "{" 480 [61]=> 481 array(3) { 482 [0]=> 483 int(%d) 484 [1]=> 485 string(5) " 486 " 487 [2]=> 488 int(13) 489 } 490 [62]=> 491 array(3) { 492 [0]=> 493 int(%d) 494 [1]=> 495 string(2) "$b" 496 [2]=> 497 int(14) 498 } 499 [63]=> 500 array(3) { 501 [0]=> 502 int(%d) 503 [1]=> 504 string(2) "++" 505 [2]=> 506 int(14) 507 } 508 [64]=> 509 string(1) ";" 510 [65]=> 511 array(3) { 512 [0]=> 513 int(%d) 514 [1]=> 515 string(3) " 516 " 517 [2]=> 518 int(14) 519 } 520 [66]=> 521 string(1) "}" 522 [67]=> 523 array(3) { 524 [0]=> 525 int(%d) 526 [1]=> 527 string(3) " 528 " 529 [2]=> 530 int(15) 531 } 532 [68]=> 533 array(3) { 534 [0]=> 535 int(%d) 536 [1]=> 537 string(4) "else" 538 [2]=> 539 int(16) 540 } 541 [69]=> 542 array(3) { 543 [0]=> 544 int(%d) 545 [1]=> 546 string(5) " 547 " 548 [2]=> 549 int(16) 550 } 551 [70]=> 552 array(3) { 553 [0]=> 554 int(%d) 555 [1]=> 556 string(2) "$b" 557 [2]=> 558 int(17) 559 } 560 [71]=> 561 array(3) { 562 [0]=> 563 int(%d) 564 [1]=> 565 string(2) "--" 566 [2]=> 567 int(17) 568 } 569 [72]=> 570 string(1) ";" 571 [73]=> 572 array(3) { 573 [0]=> 574 int(%d) 575 [1]=> 576 string(3) " 577 " 578 [2]=> 579 int(17) 580 } 581 [74]=> 582 array(3) { 583 [0]=> 584 int(%d) 585 [1]=> 586 string(5) "while" 587 [2]=> 588 int(18) 589 } 590 [75]=> 591 string(1) "(" 592 [76]=> 593 array(3) { 594 [0]=> 595 int(%d) 596 [1]=> 597 string(2) "$a" 598 [2]=> 599 int(18) 600 } 601 [77]=> 602 array(3) { 603 [0]=> 604 int(%d) 605 [1]=> 606 string(1) " " 607 [2]=> 608 int(18) 609 } 610 [78]=> 611 string(1) ">" 612 [79]=> 613 array(3) { 614 [0]=> 615 int(%d) 616 [1]=> 617 string(1) " " 618 [2]=> 619 int(18) 620 } 621 [80]=> 622 array(3) { 623 [0]=> 624 int(%d) 625 [1]=> 626 string(1) "0" 627 [2]=> 628 int(18) 629 } 630 [81]=> 631 string(1) ")" 632 [82]=> 633 array(3) { 634 [0]=> 635 int(%d) 636 [1]=> 637 string(1) " " 638 [2]=> 639 int(18) 640 } 641 [83]=> 642 string(1) "{" 643 [84]=> 644 array(3) { 645 [0]=> 646 int(%d) 647 [1]=> 648 string(5) " 649 " 650 [2]=> 651 int(18) 652 } 653 [85]=> 654 array(3) { 655 [0]=> 656 int(%d) 657 [1]=> 658 string(4) "echo" 659 [2]=> 660 int(19) 661 } 662 [86]=> 663 array(3) { 664 [0]=> 665 int(%d) 666 [1]=> 667 string(1) " " 668 [2]=> 669 int(19) 670 } 671 [87]=> 672 array(3) { 673 [0]=> 674 int(%d) 675 [1]=> 676 string(3) ""*"" 677 [2]=> 678 int(19) 679 } 680 [88]=> 681 string(1) ";" 682 [89]=> 683 array(3) { 684 [0]=> 685 int(%d) 686 [1]=> 687 string(5) " 688 " 689 [2]=> 690 int(19) 691 } 692 [90]=> 693 array(3) { 694 [0]=> 695 int(%d) 696 [1]=> 697 string(2) "$a" 698 [2]=> 699 int(20) 700 } 701 [91]=> 702 array(3) { 703 [0]=> 704 int(%d) 705 [1]=> 706 string(2) "--" 707 [2]=> 708 int(20) 709 } 710 [92]=> 711 string(1) ";" 712 [93]=> 713 array(3) { 714 [0]=> 715 int(%d) 716 [1]=> 717 string(3) " 718 " 719 [2]=> 720 int(20) 721 } 722 [94]=> 723 string(1) "}" 724 [95]=> 725 array(3) { 726 [0]=> 727 int(%d) 728 [1]=> 729 string(3) " 730 " 731 [2]=> 732 int(21) 733 } 734 [96]=> 735 array(3) { 736 [0]=> 737 int(%d) 738 [1]=> 739 string(10) "myFunction" 740 [2]=> 741 int(22) 742 } 743 [97]=> 744 string(1) "(" 745 [98]=> 746 array(3) { 747 [0]=> 748 int(%d) 749 [1]=> 750 string(2) "10" 751 [2]=> 752 int(22) 753 } 754 [99]=> 755 string(1) ")" 756 [100]=> 757 string(1) ";" 758 [101]=> 759 array(3) { 760 [0]=> 761 int(%d) 762 [1]=> 763 string(1) " 764" 765 [2]=> 766 int(22) 767 } 768 [102]=> 769 array(3) { 770 [0]=> 771 int(%d) 772 [1]=> 773 string(2) "?>" 774 [2]=> 775 int(23) 776 } 777} 778Done 779