Bug #76439 [Ver->Csd]: Changed behaviour in unclosed HereDoc

From: Date: Wed, 27 Jun 2018 12:16:07 +0000
Subject: Bug #76439 [Ver->Csd]: Changed behaviour in unclosed HereDoc
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215991@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=76439&edit=1 ID: 76439 Updated by: nikic@php.net Reported by: love at sickpeople dot se Summary: Changed behaviour in unclosed HereDoc -Status: Verified +Status: Closed Type: Bug Package: Scripting Engine problem PHP Version: 7.3.0alpha1 Assigned To: tpunt Block user comment: N Private report: N New Comment: Automatic comment on behalf of nikita.ppv@gmail.com Revision: http://git.php.net/?p=php-src.git;a=commit;h=17afe6430fffa6ca646f336dacf34fc5af865390 Log: Fixed bug #76439 Previous Comments: ------------------------------------------------------------------------ [2018-06-10 12:13:31] cmb@php.net The problem is that strip_multiline_string_indentation() is called after *any* variable[1], resulting in the parse error, if the variable is not followed by whitespace, and resulting in removed whitespace otherwise. E.g. <?php $foo = 'foo'; echo <<<BAR $foo bar BAR; outputs foobar instead of the expected foo bar. Thomas, could you please have a look at this issue? [1] <https://github.com/php/php-src/blob/php-7.3.0alpha1/Zend/zend_language_scanner.l#L2589> <https://github.com/php/php-src/blob/php-7.3.0alpha1/Zend/zend_language_scanner.l#L2594> ------------------------------------------------------------------------ [2018-06-09 22:59:42] love at sickpeople dot se The heredoc should not be considered unclosed in 7.3, since https://wiki.php.net/rfc/flexible_heredoc_nowdoc_syntaxes . The dot triggers the problem. With removed dot the script works in 7.3alpha1: https://3v4l.org/VeX0p ------------------------------------------------------------------------ [2018-06-09 22:58:12] nikic@php.net In PHP 7.3 the doc string *is* terminated. The code as written should be working fine, the indentation error is spurious. ------------------------------------------------------------------------ [2018-06-09 22:47:03] danack@php.net tl:dr - the error message for unclosed heredoc makes no sense for PHP 7.3alpaha To: Parse error: Invalid body indentation level (expecting an indentation level of at least 1) in /in/VQqm7 on line 10 From Parse error: syntax error, unexpected end of file in /in/VQqm7 on line 12 ------------------------------------------------------------------------ [2018-06-09 22:45:55] danack@php.net Running you exact code gives me the error "Parse error: syntax error, unexpected end of file in /in/VQqm7 on line 12" - https://3v4l.org/VQqm7 That's because there are spaces before the "BAR;" in your script, and the parser gets to the end of the file unexpectedly. Removing those spaces makes the script work - https://3v4l.org/19bhe However I'm going to leave this open as the error has changed for PHP7.3alpha, and it makes no sense. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=76439 -- Edit this bug report at https://bugs.php.net/bug.php?id=76439&edit=1

« previous php.bugs (#215991) next »