php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

Improve Heredoc Support

Open ejmr opened this issue 14 years ago • 5 comments

The following mode already has a good implementation:

https://github.com/pivaldi/pi-php-mode

So I need to ask him if it would be ok to borrow/adapt his work.

ejmr avatar Dec 02 '12 05:12 ejmr

yes, but it still has a problem, the line after heredoc is indented wrong , more 4 chars indented than we expected. like this:

$str = <<<"EOT"
{$var1} hello
EOT;

    $str2 = "hello, world";

guweigang avatar Dec 11 '12 16:12 guweigang

Thanks for pointing this out; it will help me make a test case. I am planning to fix the heredoc support for the next version, but right now I cannot say when that will be released. Very likely before the end of the year, but with holidays nearby I can't say where my time will end up.

ejmr avatar Dec 11 '12 23:12 ejmr

Just some thoughts, as I ran into this issue today.

As a workaround (or more inspiration), nxhtml-mode indents this correctly, except that the desired indentation level is not reverted after the closing delimiter.

Also, I didn't know about the double-quoted heredoc syntax. The RFC has some clear examples of the different types, which might help in creating test cases, although I think that the highlighting there is a bit wrong. Variables and such should be highlighted inside heredocs, but not nowdocs, reflecting their usage. Also, a nice thing that Sublime Text does with these is that it highlights both instances of LABEL nicely.

alinnow avatar Dec 27 '12 14:12 alinnow

Huh, I didn't know about that aspect of heredocs either, that which the RFC shows. I have seen a couple of different approaches to supporting heredoc syntax, nxhtml-mode's being one of them, and am starting to think now we'll have to make some amalgamation of them to cover all of the actually allowed syntax. Thanks for bringing that RFC to my attention; never knew about that.

ejmr avatar Dec 27 '12 23:12 ejmr

Philippe Ivaldi graciously let me copy his work relating to heredoc support, which I will push out into master soon. I will still need to go back and deal with nowdocs and other things described in the RFC above, though. But those can be addressed in separate Github issues.

ejmr avatar Jan 15 '13 18:01 ejmr