From:             tomas_matousek at hotmail dot com
Operating system: WinXP
PHP version:      5.1.1
PHP Bug Type:     Scripting Engine problem
Bug description:  Missing end-of-line token

Description:
------------
PHP lexer omits end-of-line characters following T_END_HEREDOC token. This
also causes incorrect output of highlight_string() function.

Reproduce code:
---------------
$code = '
<? 
  $x = <<<EOT
some string    
EOT
  $y = 2;
?>';

display_tokens(token_get_all($code));
highlight_string($code);



function display_tokens($tokens)
{
  foreach ($tokens as $token)
  { 
    if (is_array($token))
    {
      echo token_name($token[0]),"\n";
      echo $token[0],"
'",htmlentities(addcslashes($token[1],"\n\r\t")),"'\n";
    }
    else
    {
      echo "    '",htmlentities($token),"'\n";
    }  
  }
}

Expected result:
----------------
T_INLINE_HTML
311 '\r\n'
T_OPEN_TAG
367 '<?'
T_WHITESPACE
370 ' \r\n  '
T_VARIABLE
309 '$x'
T_WHITESPACE
370 ' '
    '='
T_WHITESPACE
370 ' '
T_START_HEREDOC
371 '<<<EOT\r\n'
T_STRING
307 'some'
T_ENCAPSED_AND_WHITESPACE
314 ' '
T_STRING
307 'string'
T_ENCAPSED_AND_WHITESPACE
314 '    \r\n'
T_END_HEREDOC
372 'EOT'
T_WHITESPACE
370 '\r\n  '      // '\r\n' is missing in actual result
T_VARIABLE
309 '$y'
T_WHITESPACE
370 ' '
    '='
T_WHITESPACE
370 ' '
T_LNUMBER
305 '2'
    ';'
T_WHITESPACE
370 '\r\n'
T_CLOSE_TAG
369 '?>'


<? 
  $x = <<<EOT
some string    
EOT  $y = 2;
?>

Actual result:
--------------
T_INLINE_HTML
311 '\r\n'
T_OPEN_TAG
367 '<?'
T_WHITESPACE
370 ' \r\n  '
T_VARIABLE
309 '$x'
T_WHITESPACE
370 ' '
    '='
T_WHITESPACE
370 ' '
T_START_HEREDOC
371 '<<<EOT\r\n'
T_STRING
307 'some'
T_ENCAPSED_AND_WHITESPACE
314 ' '
T_STRING
307 'string'
T_ENCAPSED_AND_WHITESPACE
314 '    \r\n'
T_END_HEREDOC
372 'EOT'         // missing '\r\n' 
T_WHITESPACE
370 '  '
T_VARIABLE
309 '$y'
T_WHITESPACE
370 ' '
    '='
T_WHITESPACE
370 ' '
T_LNUMBER
305 '2'
    ';'
T_WHITESPACE
370 '\r\n'
T_CLOSE_TAG
369 '?>'


<? 
  $x = <<<EOT
some string    
EOT  $y = 2;
?>

-- 
Edit bug report at http://bugs.php.net/?id=35655&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=35655&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=35655&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=35655&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=35655&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=35655&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=35655&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=35655&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=35655&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=35655&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=35655&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=35655&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=35655&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=35655&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=35655&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=35655&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=35655&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=35655&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=35655&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=35655&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=35655&r=mysqlcfg

Reply via email to