Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118662 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 35128 invoked from network); 19 Sep 2022 19:18:11 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 19 Sep 2022 19:18:11 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D7A521804AB for ; Mon, 19 Sep 2022 12:18:10 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS24940 176.9.0.0/16 X-Spam-Virus: No X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Mon, 19 Sep 2022 12:18:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1663615088; bh=PuK5v39A2u0qalGix0rbLhTXpMusRF6JwmoyYtXYrT8=; h=Date:Subject:To:References:From:In-Reply-To:From; b=V5PFShaXa0FNmvQCA85Udo8naql9MeUG3gpr2iw10SrUDC+sKdhiK2M+GgrvR3TNd 6m2g/4oP0zab/EX8FTS30+3U1ZTg/RGMBklDB0koD/GAy9oTpPf4FBdI5akHTXYyVJ /W/KrSnZH4zKueUSe1Spm1gpme2P9MJpn8m7LdMlyYzr4rRyJrthFtYJ2/Rn9nWYf7 3HzOa1G6PDOdfHZ+QCt8AhSEYFkNQQld4u78beGgRgfJhHkf3f6+heAVQloJjsWOYw 3JAdw9o2CecFONt8wrgB4M72wBsGcn0P3JbkHI8ZGCdceBfyeIFv1eOjMDKK/tHgB1 94uGMG24QT7Fw== Message-ID: <25c35b20-7fcf-fa10-90ae-0ce5aedc11b4@bastelstu.be> Date: Mon, 19 Sep 2022 21:18:08 +0200 MIME-Version: 1.0 Content-Language: en-US To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] One-line heredoc for better syntax highlightning From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=c3=bcsterhus?=) 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 = << 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: dbConnection->prepare($query); $statement->execute(); } } > smaller SQL queries, using one line would be an improvement, I think. A condition-less SELECT should be rare, a condition-less UPDATE or DELETE even rarer. So this "improvement" would only affect a very small number of statements in the first place and I disagree with that being an improvement even for that small number of statements, because it would be inconsistent with all the other larger statements which *are* spread across multiple lines. > Also consider that the one line will look better in your color > highlight editor. :) > I believe that code should be readable no matter the editor it is viewed in. The suggestion fails at that. Best regards Tim Düsterhus