Bug #76608 [Ver]: Heredoc end label should not require an additional trailing character
Edit report at https://bugs.php.net/bug.php?id=76608&edit=1
ID: 76608
User updated by: mattacosta at gmail dot com
Reported by: mattacosta at gmail dot com
Summary: Heredoc end label should not require an additional
trailing character
Status: Verified
Type: Bug
Package: Scripting Engine problem
PHP Version: 7.2.7
Block user comment: N
Private report: N
New Comment:
That error appears to be correct in previous versions though. Without the required line break, the
label would be part of the text instead, so it would make sense to expect T_END_HEREDOC.
Previous Comments:
------------------------------------------------------------------------
[2018-07-11 14:55:04] cmb@php.net
This does not appear particularly related to PHP 7.3, see
<https://3v4l.org/CeumU>.
------------------------------------------------------------------------
[2018-07-11 01:01:22] mattacosta at gmail dot com
Description:
------------
If a perfectly valid heredoc is not followed by an additional character, the reported error states
that an end label was expected, even though it was present.
This means that instead of removing the requirement for a trailing newline, it was in fact replaced
by a requirement for any trailing character.
Test script:
---------------
// No trailing line.
echo <<<LABEL
hello world
LABEL
Expected result:
----------------
Parse error: syntax error, unexpected end of file, expecting ',' or ';'
Actual result:
--------------
Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end
(T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76608&edit=1
Thread (7 messages)