From:             andrey at midphase dot com
Operating system: Windows XP
PHP version:      4.3.4
PHP Bug Type:     Scripting Engine problem
Bug description:  Incorrect results returned by token_get_all for heredoc

Description:
------------
When calling token_get_all with a string containing heredoc strings,
T_END_HEREDOC element contains two semicolons separated by newline and is 
followed by semicolon character.
This does not happen if heredoc string is followed by concatenation
operatior


Reproduce code:
---------------
=====================
code.php
=====================
<?php
      $x=<<<DD
  jhdsjkfhjdsh
DD
."";
      $a=<<<DD
  jhdsjkfhjdsh
DD;
  echo $a;
?>

=====================
test.php
=====================
<?php
  $tokens=token_get_all(file_get_contents("test.php"));
  print_r($tokens);
?>

Expected result:
----------------
Array
(
    [0] => Array
        (
            [0] => 354
            [1] => <?php

        )

    [1] => Array
        (
            [0] => 357
            [1] =>       
        )

    [2] => Array
        (
            [0] => 307
            [1] => $x
        )

    [3] => =
    [4] => Array
        (
            [0] => 358
            [1] => <<<DD

        )

    [5] => Array
        (
            [0] => 312
            [1] =>   
        )

    [6] => Array
        (
            [0] => 305
            [1] => jhdsjkfhjdsh
        )

    [7] => Array
        (
            [0] => 312
            [1] => 

        )

    [8] => Array
        (
            [0] => 359
            [1] => DD

        )

    [9] => .
    [10] => Array
        (
            [0] => 313
            [1] => ""
        )

    [11] => ;
    [12] => Array
        (
            [0] => 357
            [1] => 
      
        )

    [13] => Array
        (
            [0] => 307
            [1] => $a
        )

    [14] => =
    [15] => Array
        (
            [0] => 358
            [1] => <<<DD

        )

    [16] => Array
        (
            [0] => 312
            [1] =>   
        )

    [17] => Array
        (
            [0] => 305
            [1] => jhdsjkfhjdsh
        )

    [18] => Array
        (
            [0] => 312
            [1] => 

        )

    [19] => Array
        (
            [0] => 359
            [1] => DD;

        )

/*    [20] => ;  deleted */
    [21] => Array
        (
            [0] => 357
            [1] =>   
        )

    [22] => Array
        (
            [0] => 314
            [1] => echo
        )

    [23] => Array
        (
            [0] => 357
            [1] =>  
        )

    [24] => Array
        (
            [0] => 307
            [1] => $a
        )

    [25] => ;
    [26] => Array
        (
            [0] => 357
            [1] => 

        )

    [27] => Array
        (
            [0] => 356
            [1] => ?>
        )

)


Actual result:
--------------
Array
(
    [0] => Array
        (
            [0] => 354
            [1] => <?php

        )

    [1] => Array
        (
            [0] => 357
            [1] =>       
        )

    [2] => Array
        (
            [0] => 307
            [1] => $x
        )

    [3] => =
    [4] => Array
        (
            [0] => 358
            [1] => <<<DD

        )

    [5] => Array
        (
            [0] => 312
            [1] =>   
        )

    [6] => Array
        (
            [0] => 305
            [1] => jhdsjkfhjdsh
        )

    [7] => Array
        (
            [0] => 312
            [1] => 

        )

    [8] => Array
        (
            [0] => 359
            [1] => DD

        )

    [9] => .
    [10] => Array
        (
            [0] => 313
            [1] => ""
        )

    [11] => ;
    [12] => Array
        (
            [0] => 357
            [1] => 
      
        )

    [13] => Array
        (
            [0] => 307
            [1] => $a
        )

    [14] => =
    [15] => Array
        (
            [0] => 358
            [1] => <<<DD

        )

    [16] => Array
        (
            [0] => 312
            [1] =>   
        )

    [17] => Array
        (
            [0] => 305
            [1] => jhdsjkfhjdsh
        )

    [18] => Array
        (
            [0] => 312
            [1] => 

        )

    [19] => Array
        (
            [0] => 359
            [1] => DD;
;
        )

    [20] => ;
    [21] => Array
        (
            [0] => 357
            [1] =>   
        )

    [22] => Array
        (
            [0] => 314
            [1] => echo
        )

    [23] => Array
        (
            [0] => 357
            [1] =>  
        )

    [24] => Array
        (
            [0] => 307
            [1] => $a
        )

    [25] => ;
    [26] => Array
        (
            [0] => 357
            [1] => 

        )

    [27] => Array
        (
            [0] => 356
            [1] => ?>
        )

)


-- 
Edit bug report at http://bugs.php.net/?id=26463&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=26463&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=26463&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=26463&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=26463&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=26463&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=26463&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=26463&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=26463&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=26463&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=26463&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=26463&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=26463&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=26463&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=26463&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=26463&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=26463&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=26463&r=float

Reply via email to