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
Syntax highlighting bug when using HEREDOC
Upgrade to Sublime Text 3, syntax highlighting has been vastly improved since ST2.
I was thinking that too, but it’s still there - https://github.com/sublimehq/Packages/blob/4c149aa6e9756fec6c1584f32b9fcf3d3d8e4301/PHP/PHP%20Source.sublime-syntax#L783
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.
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.
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
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.
This topic is three years old. Whatever was said about the subject in 2016 is likely no longer valid or relevant.
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.
@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”