Re: One-line heredoc for better syntax highlightning

From: Date: Mon, 19 Sep 2022 19:04:07 +0000
Subject: Re: One-line heredoc for better syntax highlightning
Groups: php.internals 
Request: Send a blank email to internals+get-118660@lists.php.net to get a copy of this message
> I don't find that example particularly readable or convincing. It mushes > together PHP and MySQL keywords too much. > > Once you add a WHERE clause that SQL query should be split across > multiple multiple lines for readability anyway and even for that very > simple example I personally would add a linebreak in front of the FROM: > > $query = <<<MySQL > SELECT * > FROM foo > MySQL; > > Best regards >Tim Düsterhus That looks good in isolation, but consider the following short snippet: class Foo { public function bar() { $query = <<<MySQL SELECT * FROM baz MySQL; } } As you can see, the heredoc breaks the reading flow completely. For smaller SQL queries, using one line would be an improvement, I think. Also consider that the one line will look better in your color highlight editor. :) Olle

« previous php.internals (#118660) next »