Bug #76608 [Com]: Heredoc end label should not require an additional trailing character

From: Date: Wed, 03 Apr 2019 17:47:55 +0000
Subject: Bug #76608 [Com]: Heredoc end label should not require an additional trailing character
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-220301@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76608&edit=1 ID: 76608 Comment by: chasepeeler 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: Yes, in 7.3, the documentation states: "The closing marker for doc strings is no longer required to be followed by a semicolon or newline." https://www.php.net/manual/en/migration73.new-features.php#migration73.new-features.core.heredoc However, if you don't include a semicolon, you get an error: <?php $str = <<<FOO abcdefg FOO echo $str; > Parse error: syntax error, unexpected 'echo' (T_ECHO) in /in/eTKHe on line 7 If you add a semicolon after FOO, everything works. This is against 7.3.3: https://3v4l.org/eTKHe Previous Comments: ------------------------------------------------------------------------ [2018-07-11 17:57:49] mattacosta at gmail dot com 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. ------------------------------------------------------------------------ [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

« previous php.bugs (#220301) next »