Re: One-line heredoc for better syntax highlightning

From: Date: Mon, 19 Sep 2022 19:23:08 +0000
Subject: Re: One-line heredoc for better syntax highlightning
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-118663@lists.php.net to get a copy of this message
2022-09-19 21:18 GMT+02:00, Tim Düsterhus <tim@bastelstu.be>: > Hi > > On 9/19/22 21:04, Olle Härstedt wrote: >> 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 > > The closing marker of the heredoc may be indented as of PHP 7.3, so the > appropriate comparison would be this: > > <?php > > class Foo > { > public function __construct( > private \PDO $dbConnection > ) {} > > public function bar() > { > $query = <<<MySQL > SELECT * > FROM baz > MySQL; > $statement = $this->dbConnection->prepare($query); > $statement->execute(); > } > } Pff, that's the second time today 3v4l gives me complete faulty results in its syntax checker. Guess it's out of date. Thanks for correcting me here. Olle

« previous php.internals (#118663) next »