Sublime Forum

Syntax highlighting bug when using HEREDOC

#1

Hello,
I am experiencing a problem with highlighting when using HEREDOC.
As soon as I use it, the rest of the document stays yellow and is not highlighted anymore.
Any ideas how to fix this? Image is below.
Thanks,
Krytos

0 Likes

#2

Upgrade to Sublime Text 3, syntax highlighting has been vastly improved since ST2.

0 Likes

#3

Since this highlighting would use back-reference, it would be removed I guess…

0 Likes

#4

I was thinking that too, but it’s still there - https://github.com/sublimehq/Packages/blob/4c149aa6e9756fec6c1584f32b9fcf3d3d8e4301/PHP/PHP%20Source.sublime-syntax#L783

0 Likes

#5

I tried to upgrade to ST3. However, nothing has changed, still the same issue :frowning:

0 Likes

#6

works fine for me (on build 3111)

0 Likes

#7

Downloaded and tried 3111, still nothing. Are you using any packages?

0 Likes

#8

Nope, just tried with a clean install of 3103 even:

0 Likes

#9

That’s a pop pattern.

Back-references don’t work in pop patterns like they would normally. Instead, the “back reference” is replaced with the corresponding match’s group that pushed the context.

2 Likes

#10

ah understood, thanks for info :slightly_smiling:

0 Likes

#11

Your problem is that you are indenting the closing indicator of the heredoc string. That’s invalid. It works if the closing indicator is not indented, as shown in @kingkeith’s screenshots.

See http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc.

3 Likes

#12

I tried $kingkeith 's version, it didn’t work either. I just found a solution - when I use tab before the closing indicator, it doesn’t work, BUT if I start the line with ADMIN_FORM; without any spaces or tabs before, the highlighting works

1 Like

#13

Now indented heredoc syntax is valid in php 7.3+. Maybe it’s a time to fix heredocs and statement: ... endstatement; folding in Sublime? Really annoying.

0 Likes

#14

This topic is three years old. Whatever was said about the subject in 2016 is likely no longer valid or relevant.

0 Likes

#15

Yeah. https://github.com/sublimehq/Packages/pull/1634

But ST’s release pace is kinda slow, if you wish to always use the latest syntax definition files, you have to do it by yourself currently.

0 Likes

#16

@jfcherng oh thank you! I didn’t watch github before.

@ThomSmith I wouldn’t raise such an old topic if it were “no longer valid or relevant”

0 Likes