[vim/vim] PHP syntax broken for heredoc quotes (Issue #12952)

26 views
Skip to first unread message

tlathm

unread,
Aug 29, 2023, 9:46:29 AM8/29/23
to vim/vim, Subscribed

Steps to reproduce

Edit any PHP code that uses heardoc syntax with escaped dollar signs ($)

Expected behaviour

The following PHP code:

print <<<END
\$somevar
END;

...highlights the "$somevar" as a variable and not the literal text. I know this used to work correctly, and I'm unclear as to specifically which version broke it.

Version of Vim

9.0.1503

Environment

Gentoo Linux
TERM=rxvt
Shell: bash

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952@github.com>

dkearns

unread,
Aug 29, 2023, 10:07:38 AM8/29/23
to vim/vim, Subscribed

If you haven't already done so you should try approaching the maintainer, listed in the header, first.

https://github.com/TysonAndre/php-vim-syntax


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1697514554@github.com>

stefanos

unread,
Aug 29, 2023, 10:20:26 AM8/29/23
to vim/vim, Subscribed

This is an expected behavior; please, do not confused Heredoc and Nowdoc.

If you want to highlight it as literal text, just enclose your opened Nowdoc in single quotes:

image


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1697540897@github.com>

Christian Brabandt

unread,
Aug 29, 2023, 10:27:15 AM8/29/23
to vim/vim, Subscribed

Closed #12952 as not planned.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/12952/issue_event/10222067124@github.com>

Christian Brabandt

unread,
Aug 29, 2023, 10:27:16 AM8/29/23
to vim/vim, Subscribed

closing then.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1697554734@github.com>

tlathm

unread,
Aug 29, 2023, 2:48:01 PM8/29/23
to vim/vim, Subscribed

I get the difference between the two, but have to disagree on the assessment here when it comes to the specific case where the dollar sign is escaped. Even a simple double quoted string correctly shows that as text and not a highlighted variable:

<?php
print "This is \$somevar\n";

That gets handled correctly. How is the current behavior within a HEREDOC correct?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1697958919@github.com>

stefanos

unread,
Aug 29, 2023, 3:12:32 PM8/29/23
to vim/vim, Subscribed

Replace END with another word, for instance EOD and it should behave as expected; but please, read again very closely the whole https://www.php.net/manual/en/language.types.string.php because it contains valuable information in it, especially around string quotes versus double quotes and their parsing mechanism.

I like calling such information hidden pearls.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1697990767@github.com>

tlathm

unread,
Aug 30, 2023, 7:25:34 AM8/30/23
to vim/vim, Subscribed

Wow. OK yes...I see you're correct about using something other than END. I don't understand why using that specific string is highlighted differently however(?), and I don't see anything in that documentation related specifically to the END quoting string. From a PHP standpoint it functions identically to any other.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1698977431@github.com>

stefanos

unread,
Aug 30, 2023, 7:48:31 AM8/30/23
to vim/vim, Subscribed

I don't understand why using that specific string is highlighted differently however(?), and I don't see anything in that documentation related specifically to the END quoting string. From a PHP standpoint it functions identically to any other.

I presume the word end (case insensitive) is being recognized from PHP syntax as part of SQL support (BEGIN ... END); it's enabled by default if I'm not mistaken.

You can find more in Vim via :h ft-php-syntax.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1699013049@github.com>

dkearns

unread,
Aug 30, 2023, 8:28:17 AM8/30/23
to vim/vim, Subscribed

It's the end function matching there with higher priority as it's a syn-keyword. I won't throw a fix at the wall unless the maintainer fails to come up with something soon.

Feel free to ping me if you have no luck.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1699073055@github.com>

tlathm

unread,
Aug 30, 2023, 10:25:58 AM8/30/23
to vim/vim, Subscribed

Ahhh...OK, that makes total sense. As you see above I've logged a bug with the maintainer. I'll add to that and we'll see what he says. I actually wasn't aware you could even call functions using names in upper case like END() which for me is sort of horrifying :D. Thanks a million for the clarification!


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/12952/1699289356@github.com>

Reply all
Reply to author
Forward
0 new messages