2022-09-20 17:00 GMT+02:00, Sara Golemon <poll...@php.net>:
> On 19 September 2022 15:24:26 BST, "Olle Härstedt" <
> olle.haerst...@limesurvey.org> wrote:
>>Some editors can guess the domain-specific language inside heredoc, e.g.
> if you do
>>
>>$query = <<<MySQL
>>SELECT * FROM foo
>>MySQL;
>>
>>It would be nice if this feature could be used in single lines as well:
>>
>>$query = <<<MySQL SELECT * FROM foo MySQL;
>>
> Good news! This feature exists and was introduced by Rasmus **checks
> notes** about 25 years ago.
>
> To use it, you'll want to hold down your shift key, then press the key just
> to the left of your enter key.  This is called a "quote", and you can see
> it demonstrated here around the word quote.
>
> Hope that helps!
>
> Seriously though, I know you're looking to help your editor find something
> to syntax highlight, but this is an editor problem, not a PHP language
> problem.  If your editor can detect SQL in heredoc, then it should be able
> to improve and find it in interpolated strings.

Nope, because you need to be explicit which type of SQL you're working
with - MySQL, Postgres, SQL Server, etc. Would be hard to write a
regexp to guess that for the editor. :) In the Vim case, it reads your
delimiter name and applies syntax highlight from that (mysql,
javascript, html).

> Making the parser more
> complex for no benefit to the actual language (some detriment, I would
> argue) is not the fix here.
>
> -Sara
>
> P.S. - Yes, I'm assuming a US layout, you know where your quote key is.

I you read my text more carefully, you'd see that I thought the parser
would be simplified by my suggestion, by removing what I thought was
an arbitrary limitation. I was wrong. :(

Olle

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to