Bug #77812 [Com]: Interactive mode does not recognize PHP 7.3-style heredoc closing identifier

From: Date: Sat, 17 Aug 2019 12:49:48 +0000
Subject: Bug #77812 [Com]: Interactive mode does not recognize PHP 7.3-style heredoc closing identifier
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-222287@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: blackknight at iinet dot net dot au Reported by: bugs dot php dot net at ss dot st dot tc Summary: Interactive mode does not recognize PHP 7.3-style heredoc closing identifier Status: Re-Opened Type: Bug Package: Readline related Operating System: * PHP Version: 7.3 Block user comment: N Private report: N New Comment: I've just had a look around and it might be a bit fiddly to fix. Around line 354 of ext/readline/readline_cli.c. Allowing whitespace between the start of line and the heredoc tag shouldn't be too difficult, but the new syntax also allows the tag to be followed by code other than just \n or ;\n - will need some way to distinguish END, $somethingElse); from ENDING inside the heredoc. Previous Comments: ------------------------------------------------------------------------ [2019-08-17 12:22:53] requinix@php.net Looks like the fix will be to ext/readline's cli_is_valid_code(). ------------------------------------------------------------------------ [2019-08-17 12:19:02] requinix@php.net I've split the doc bug out into bug #78425, since this report has a fair bit of commentary about the interactive mode bug. ------------------------------------------------------------------------ [2019-08-17 12:10:09] blackknight at iinet dot net dot au Would it be worth splitting this into two issues? This one is currently classified as a documentation issue, but the interactive mode issue seems quite distinct. ------------------------------------------------------------------------ [2019-08-01 21:33:33] santiagoarizti at gmail dot com 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 ------------------------------------------------------------------------ [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; <<< > ------------------------------------------------------------------------ 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.bugs (#222287) next »