Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128320 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 A2AF51A00BC for ; Thu, 31 Jul 2025 04:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753937519; bh=1lb7XaEM8MumrxKnXs1u4921ZCMruIAWCfNLF6LepZE=; h=From:Date:Subject:To:From; b=Ba1dm3pHtVt3r1M5AQgf+59HGQRuWyjk6+4NTW9KRa57V2DSRPCnE9fGdL8iSPeuq evp/m/NfgJqsvxtCrh8qOjC6wjH7P3Jg8a8L231OFCjYbOQGDzUoHj4P/fDDWZzrcg eHHEL+LUnFMX9pgojmR3USp4cvtGlN3+FcAHKkyLeoujZFhRqZWNuTecldXpGAtu/9 i1BG44haHyukr5+FLzkgs9yIIfsX/7N3raEGSOeePuLwUklY2X52Pa+Fnmd14JU06D /sLS8z53MGIEctzX3wJBZbZoUAho00RREc3wR3Eyq4W3NLvJhWYfxkAnjUWYRkUQH8 jtqsx2CGAIYhg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8601B180069 for ; Thu, 31 Jul 2025 04:51:58 +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=-1.2 required=5.0 tests=BAYES_40,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, 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: <91liahim@gmail.com> Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) (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 04:51:55 +0000 (UTC) Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-e8fd38cb3a1so213152276.3 for ; Wed, 30 Jul 2025 21:53:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753937616; x=1754542416; darn=lists.php.net; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=pDVQsB0zdKGjIHW49/oq2dtaxZOe5KR7CsUT+eogFVU=; b=SvWZD0ttKYJsIEDNblEMwz7ypMobtc8bt1Y5TqT6aTkTZsMJnR9OjdYSqYCPJNzw8I A01ywRxFw0hKIWvhoLmtUt+OuZtJgRnbskFB93osF5+Ma8YDeW/khc5HdZebvksysTMF MRyWxNSVUNCwsJGUvpkLm8x/GYu/3Hp3fUaKB0kfqRGeRvoukwJxELAS5G2mHhNyCOQN aGhEi1sJdVtqi1aSwrPQLjUn26VGDARdmGhVUbaBzKONwpp6b/hWfoCvhx7D+v1WKOGV xW1eJF931c4oc8YGOSAuRsqRzskQRJrHiCPQ641Qie0bOEFXwCRmBt+cKY/sJZugFp+U Qp7Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753937616; x=1754542416; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=pDVQsB0zdKGjIHW49/oq2dtaxZOe5KR7CsUT+eogFVU=; b=KMyPHrprQYe0WbFdeTHfwZEg0dmoH8RRsFIP8f1kxXDbzZ8KNH7H4JVdYuHtiX8fdO KrKuMRrH30RxSEbqx7NziYcXCT6PD7K5tLOOXYNwBeyhalmFNSPqWdfpf2PSwFdDe55p HvCb38SP6F/DYok2NfWJO577zvt926L9llCDKk/kZxzyn/LZzqnPq0QXEat9f46DH3g9 uaWEgEksdIlv5EsYQT6tz3Tns27b6SCMnc5RmtXJLhhs5hAXrHiJ/8Zr4uaQfqBsaAUA zhKgWV8kpfSLmOt0+Od/XaPUseE9ZWlxQ5C8n/5IATtcgrmEgBEdiqPAyTIgNkUlh+hs nabQ== X-Gm-Message-State: AOJu0YxKA+7SSeGN2H5KwSfgETKCdvrdZslaeq35/4CeY+PZic/52qHh hb17iGVsgjdK6v4PB6nXUd54TtPf+3v27B7l3HkQALHC+FfDmL9eupSYeMkHpVmFD9ulOoOiEqp o1R2BbIIKbr9sGxYJerKxwJjA0f5AahRyipgd X-Gm-Gg: ASbGncveE/ema+3Fje2LcrV1yq/5xM3tPBXH5H/V4d2JB8Sw+I1YzJPOKkkBib/n0qX OCDaWvAT756NwwPv3k1FDj8HEDatml1cqRMuRNF2zivit2QuMCz4JEDO8N4XT+PNBqqvuZarVIp h1A6njOkx5+YQVr2y0E/VmcwyUdhN584GVJMMwas/qhh0chY9FkIE2JCLRWflvlJlDPDRwk++WO 9HjPuA= X-Google-Smtp-Source: AGHT+IGfhUu3Otv0Cz3P0zaF+ca2RpOit89SdlaLca7A03QxtnVd6H9QYBu0RM8TEMNpUQarUpCtflb1rkwoMy05jG4= X-Received: by 2002:a05:6902:c03:b0:e8d:8685:b89f with SMTP id 3f1490d57ef6-e8e31566e61mr6926052276.25.1753937616479; Wed, 30 Jul 2025 21:53:36 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 31 Jul 2025 09:53:25 +0500 X-Gm-Features: Ac12FXw1z2URh03oF9o7jpy0lOnBF_OFxK5aqM3LCOjzl4FEpVxoES9dxRpFqK0 Message-ID: Subject: [PHP-DEV] [RFC] Optional Catch Block Body To: PHP internals Content-Type: multipart/alternative; boundary="00000000000096aab8063b326cd7" From: 91liahim@gmail.com (Mihail Liahimov) --00000000000096aab8063b326cd7 Content-Type: text/plain; charset="UTF-8" Introduction Currently, PHP requires a block body for catch clauses even when the caught exception is not used. This results in unnecessary boilerplate code. This RFC proposes allowing catch clauses without a body when the exception variable is omitted. Proposal Allow the following syntax where the curly braces can be omitted when no exception variable is specified and no handling is needed: try { // code that may throw } catch (SomeError); This would be equivalent to: try { // code that may throw } catch (SomeError) {} Motivation 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. Backward Incompatible Changes None. This is purely an additive change to the syntax. --00000000000096aab8063b326cd7 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Introduction

Currently, PHP requires a block body f= or catch clauses even when the caught exception is not used. This results i= n unnecessary boilerplate code. This RFC proposes allowing catch clauses wi= thout a body when the exception variable is omitted.

Proposal
Allow the following syntax where the curly braces can be omitted when no e= xception variable is specified and no handling is needed:

try {
= =C2=A0 =C2=A0 // code that may throw
} catch (SomeError);

This wo= uld be equivalent to:

try {
=C2=A0 =C2=A0 // code that may throw<= br>} catch (SomeError) {}

Motivation

Reduced Boilerplate: Eli= minates 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.

Backward Incompatible Changes

None. T= his is purely an additive change to the syntax.

--00000000000096aab8063b326cd7--