Doc #77812 [Com]: 7.3 heredoc syntax not documented in manual proper

From: Date: Thu, 01 Aug 2019 21:33:34 +0000
Subject: Doc #77812 [Com]: 7.3 heredoc syntax not documented in manual proper
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-16848@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=77812&edit=1 ID: 77812 Comment by: santiagoarizti at gmail dot com Reported by: bugs dot php dot net at ss dot st dot tc Summary: 7.3 heredoc syntax not documented in manual proper Status: Re-Opened Type: Documentation Problem Package: Strings related Operating System: * PHP Version: 7.3 Block user comment: N Private report: N New Comment: Ok, after a little bit more playing around with interactive mode, I found the problem, but I cannot fix it. The php interpreter is ok, it is just the interactive mode that is not recognizing the end of the flexible heredoc. But, with this combination of lines the interpreter behaves "correctly" santiagoarizti@santis-mac:~$ docker run --rm -it php:7.3 Interactive shell php > echo <<<EOF <<< > let us see <<< > EOF /* <<< > EOF php > */ php > ; let us see php > I gave the interpreter the old expected ending, but inside a multiline comment, so it doesn't complain about a missing constant... perhaps that gives an idea of what is causing the issue Previous Comments: ------------------------------------------------------------------------ [2019-08-01 21:24:21] santiagoarizti at gmail dot com The problem in php interactive mode is still there. Here I show How I create a php file and add a simple function that echoes a string from a heredoc. But the same function in interactive mode is not even recognized as a complete heredoc, so I cannot even close the function. see this: santiagoarizti@santis-mac:~$ docker run --rm -it php:7.3 bash root@a8df21f382dd:/# echo -e '#!/usr/local/bin/php\n<?php\nfunction sayHello($name) {\n echo <<<EOF\n hola $name\n EOF;\n}\nsayHello($argv[1]);echo PHP_EOL;\n' > santi.php root@a8df21f382dd:/# cat santi.php #!/usr/local/bin/php <?php function sayHello($name) { echo <<<EOF hola $name EOF; } sayHello($argv[1]);echo PHP_EOL; root@a8df21f382dd:/# php santi.php Santiago hola Santiago root@a8df21f382dd:/# php -a Interactive shell php > function sayHello($name) { php { echo <<<EOF <<< > hola $name <<< > EOF; <<< > } Notice how I am still inside heredoc according to php. Here is a simpler example without anything but an echo: santiagoarizti@santis-mac:~$ docker run --rm -it php:7.3 Interactive shell php > echo <<<EOF <<< > this works fine, <<< > old syntax <<< > EOF; this works fine, old syntax php > echo <<<EOF <<< > this doesn't <<< > work, new syntax <<< > EOF; <<< > ------------------------------------------------------------------------ [2019-04-03 21:07:09] chasepeeler at gmail dot com So, it doesn't appear the other issue I mentioned in my previous email is actually a bug. The fact that the migration documentation is incorrect still applies, though. ------------------------------------------------------------------------ [2019-04-03 17:54:07] chasepeeler at gmail dot com The documentation at https://www.php.net/manual/en/migration73.incompatible.php#migration73.incompatible.core.heredoc-nowdoc is definitely wrong. As written: <?php $str = <<<FOO abcdefg FOO FOO; ?> will not produce the error mentioned. Instead, it will give the following: Parse error: Invalid body indentation level (expecting an indentation level of at least 4) If you don't indent that line: <?php $str = <<<FOO abcdefg FOO FOO; ?> You'll get an error, but still not the one reported. This appears to be a bug though, as it's requiring a semicolon after the identifier, despite the fact that documentation says that is no longer required. See https://bugs.php.net/bug.php?id=76608 ------------------------------------------------------------------------ [2019-03-28 09:54:54] cmb@php.net > […] which doesn't even mention new syntax. Re-opening as doc bug, then. ------------------------------------------------------------------------ [2019-03-28 00:11:20] bugs dot php dot net at ss dot st dot tc Oh thank you so much. I didn't look there. Instead, was staring at https://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc which doesn't even mention new syntax. Thanks again. ------------------------------------------------------------------------ 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=77812 -- Edit this bug report at https://bugs.php.net/bug.php?id=77812&edit=1

« previous php.doc.bugs (#16848) next »