Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128332 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id 118051A00BC for ; Thu, 31 Jul 2025 08:10:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753949297; bh=9zA76k8682t18/I7b7ni+GmRr5CL3u6byoHXyd1i50w=; h=Date:Subject:To:References:From:In-Reply-To:From; b=L2Nh78O24UD3yWwH7/IUaJ2rP1OVzPuPBs216xZtA93zHv/7ByzSwtP70hpE5N/5H HHsQcuAsRrXDFkRkkZP+J1o2DpTJ0fn2COj2UIPIuNeovr21CJkwqU47MJZC8uY7ba 0n8ZD9yLe+xK6CY9uQbm6krhne2mDPI62Q+RV9C6aU1V8sP8Z4Hrvw8P1s8vQaTeyT WC4a3yOaNDtk/sML2UWn5X8gil64hC0NdqWwid20obFfYw/Xvg4PJpxbDsG2VqThPl ud90uAkGkznvaAMoXLSrAc+VDg/D5iLcGGSMBNMak9+5+8/ly6CMfWFeguvX/7xAJB yHRifSd0qWL3Q== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A38A0180086 for ; Thu, 31 Jul 2025 08:08:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from fhigh-a5-smtp.messagingengine.com (fhigh-a5-smtp.messagingengine.com [103.168.172.156]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 31 Jul 2025 08:08:16 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfhigh.phl.internal (Postfix) with ESMTP id 0ECEA14000E3 for ; Thu, 31 Jul 2025 04:09:58 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-03.internal (MEProxy); Thu, 31 Jul 2025 04:09:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1753949398; x=1754035798; bh=+pOz3B4NedT9rPRtTjY4/V7EsVKRwkWuyko4PS1yTVI=; b= HV7KjptOhKumQ/OyOI6ZZJrsX2+ELqpkgeRifBMKMAYpFFJGNwtE3RX8shpxhMxK s47W8eO9rUaNn411QcpgN0O6ScCwcdMyiOCcYVIO/Q62TMVuahdmrk4QCe5Qnwi2 GzkO/fblW3c+zkj4eaS6RpGJsY6zOVAT9btRmKXtjtbmbih3tmLNPapM20oCsxdr E/IAk5QnRMxcGPHaEkJBz/DhNke/0LlB2Jm3enno2RjRfN/+RXPjS73USutI7JpG kgbjtZtLUXO4VrkYtR5fYO+ViZRsgN3hxRSnESQxTiZ4O7tejFv+lkrPOttmZ9cd XvrrbdwL01QyjvMXDcIvGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1753949398; x=1754035798; bh=+ pOz3B4NedT9rPRtTjY4/V7EsVKRwkWuyko4PS1yTVI=; b=M/D9vhXhEXYrZ3lxj pd780eylB0u4ggUqz9ykvm7pGFSbBcehKd4UKTlYwJOJKMpgK1p8cpgNVZgW3/Sn QF679UKFoYMeRJ536BhQZEhIe74MLuKOUYfzO/CVbpnKiogoivMGLN0vwo3v8MVk YVUcqB0w+6L5i6U0TX/0PCHECxJ1jAcoh+7UTWe4l0w/EBj/v4S3A66BoHtfSrj5 uMEt220O6hsKLoVFsqavw8e30xXNDZ9WsoCztk4mCxFEZw23xKS4rUtydKZuvqNE zZw97vFC2FxpBRrHVy0KmFR8+BHxRshXi7FxgAoDoCw5Le1aW5s3x6PSpC0Pf246 SOUEw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdefgddutddtfedtucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucenucfjughrpefkffggfgfuvfhfhfgjtgfgsehtjeertd dtvdejnecuhfhrohhmpedftfhofigrnhcuvfhomhhmihhnshculgfkoffuohfrngdfuceo ihhmshhophdrphhhphesrhifvggtrdgtohdruhhkqeenucggtffrrghtthgvrhhnpeejke fghfeugffgtdeuheeggfdugefhudekjefhteegieejleehveelhfefvdfhudenucevlhhu shhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehimhhsohhprdhphh hpsehrfigvtgdrtghordhukhdpnhgspghrtghpthhtohepuddpmhhouggvpehsmhhtphho uhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrphhhphdrnhgvth X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 31 Jul 2025 04:09:57 -0400 (EDT) Message-ID: <095f25f5-695b-46d4-9f31-5d7e7a04ce05@rwec.co.uk> Date: Thu, 31 Jul 2025 09:09:56 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] [RFC] Optional Catch Block Body Content-Language: en-GB To: internals@lists.php.net References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 31/07/2025 05:53, Mihail Liahimov wrote: > Reduced Boilerplate: Eliminates unnecessary empty blocks when > exceptions only need to be caught and ignored. > Improved Readability: Makes the code more concise and focuses on the > important parts. The "boilerplate" in question is a single saved byte - ";" instead of "{}". Depending on keyboard layout one or the other might be slightly easier to type. Readability is always subjective, but I think most PHP programmers would quite easily read "{}" as "do nothing". I suspect the real motivation here is that *coding standards* require more boilerplate than the language in this case, such as a newline between the opening and closing brace. But PHP is not Python, where whitespace is enforced by the compiler; nor is it Go, where a coding standard is part of the standard library; so this is not the right place to change coding standards. Even if we add the short-hand syntax, there is nothing to stop those coding standards forbidding its use. As others have said, good uses of empty catch blocks are rare - generally, you want to at least log that the exception happened, and where it was caught. And even those which are functionally empty often benefit from a comment explaining why they're not doing anything, which sits naturally between the braces. If for some reason your project is commonly using completely empty catch blocks, you can document where and why "catch(Foo){}" is allowed in your local coding standard. -- Rowan Tommins [IMSoP]