php: Add syntax highlighting inside heredoc strings (#18368)

PHP heredoc strings make it easy to define string literals over multiple
lines:

```php
    $someString = <<<EOT
        multiline
        text
        EOT;
```

That `EOT` identifier can be anything else, and it is actually being
used in Sublime Text and VS Code to inject syntax highlighting for
another language in said string, depending on the identifier. For
instance, if the identifier is SQL, SQL syntax highlighting will be
applied to the contents of the string. Likewise if the identifier is CSS
or JS.

```php
    $someString = <<<SQL
        SELECT *
        FROM my_table
        SQL;
```

This PR changes the PHP extension so that it supports that feature too.

Release Notes:

- php: Added syntax highlighting inside heredoc strings
This commit is contained in:
Sylvain Brunerie 2024-09-30 09:02:12 +02:00 committed by GitHub
parent 5b40debb5f
commit 898d48a574
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5,3 +5,5 @@
((comment) @content
(#match? @content "^/\\*\\*[^*]")
(#set! "language" "phpdoc"))
((heredoc_body) (heredoc_end) @language) @content