Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128328 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 7FC921A00BC for ; Thu, 31 Jul 2025 07:02:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753945273; bh=pDbTGXobbPv9rFV9FMHGWYif8ViIGcQ7J/Fml5z0vFA=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=FZKCVHF6L6pqXquAs2fUtLTBDsAXoM5vfpGapk2X9l/GO71KxtofCAX2rRO5w5hmV 4AN0Xxh1VcZJbh4ve/EwHZxgbNpmc5GcI5cm1dylekgW1ro01FibJMRobvnFUcgs30 lVdNQznR5VsPZrjSyi8K50Qpd0Rv3ARFtnBsIhQvRkirCu0q/SAJ63FvylVPWJoyaS 72fRSBavn7MP3QxlgKPpv2t5GNyJC/Ad4BKqPQwd7dpVqMPncQ1Pmd53uREEdDf8tw /QnEk3vbKhFS6jYsYtywPmvdl1N2rVoT5YQpAJBa9y3RlJQ/GPd7oBpwQgxNhIWRAo S8frWQ379nzPQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 5A85C180381 for ; Thu, 31 Jul 2025 07:01:12 +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=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, FREEMAIL_REPLY,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-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) (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 07:01:12 +0000 (UTC) Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-e8fd07da660so563452276.2 for ; Thu, 31 Jul 2025 00:02:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1753945373; x=1754550173; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=pDbTGXobbPv9rFV9FMHGWYif8ViIGcQ7J/Fml5z0vFA=; b=jzL1yy9nKTpcU0eg/NIElu/U+6fTxLIUa9iZX7IEHQW+ZPtolt3kYqfAFZzCMnVliW PAjiyDSsr+Ieyqk7JA6c+AVqSPpE7+G6U5Ti5xgY7v7HJ1dZ+6OS2uo+UFQyrAje8TjJ Pfs2GqRNmHQO4gMzr4c7aDzMEjI/Ai5A4UTDMBA1X4jKzrlilo4OB2d4HouqRmtqtzrB NtYVFeTqHxIPPW05duevuJ0dqdC+PMEo0CVa+0H30mi1DnUocwGDuM60OZmoJ51Zm17U zi7hZApAaS6f493YlTPeiNfie/81MRLt6hC2ZKsDsZJg/LYhkLTRcXp/LfLRB/trmfaZ YXGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753945373; x=1754550173; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=pDbTGXobbPv9rFV9FMHGWYif8ViIGcQ7J/Fml5z0vFA=; b=X62ZYteVfxXNbV4BEnuKH7UYsHs/BAAM1uh2MkuH1o7PdyD7agP9Nuknx7Eym5Yg4k e6v6rlu9tv3HgvpM1Ykim0gNpd9CkJPxxIRR+nlcrGySg0BbtWi7QY8sSGNJsAz7tmXu cApa9F42IPW+mzfn16EbVUGt4b+GzIDAdG5ulGRUtfboDoQH9r2BD/Iu3yphZc1J+ZII mi3OcYudu8Le8vDmentlg9j6QCtWoK6W7t5R6Juk9C7pc4OuZFovrW/d8MPpFZVQdjlN cHKpR5bzXPA8P0M+zEo1danvkozoGyhE+0AqkHfkg9f0TLFwYpSMRTrWg72owgrebQa7 IH6Q== X-Forwarded-Encrypted: i=1; AJvYcCX7jGz7itYcvgQRF5PwXhJ9CnJLJZN+zHNghMS2klHBaRPh6lAp2OVZ0wzA73LtMuvI0E6ylI9BZ/k=@lists.php.net X-Gm-Message-State: AOJu0YwquCVdZ4mZurPvyebftGceuKCFdikFRTH9YG6ZXezU4JW6AmIQ vbySmFuLcLJrVlZB0SczmDl885CIOMH+eSu2gVmx6Lix2Dn6kw7x3NF6StCuxHLb1E0+kgc2nXC Ygxvr7+DIzWFFynYuqUgsBq3R3HKbmyk= X-Gm-Gg: ASbGncvy4l94AWPV6ONR7o7eEeD3fr/bllCHsE94fCQ/rykQI0Lc6T79VmoZ+kQPcYL 14Bc5K00q3jpuV4IQU7ZUzEpmA5B3MnsA5hQzuq0JYTI8FVBNLc/rPibUeTsQr9LVzc8tP03Zsx 4brv/XE8blzroACLEksJb9hB3612JNS51SDE28XodElKz6IrU07EFqicL8V7lzPjwDO/7ZfS/a3 yCLK/DJNqGYaKF8KYwgNKYrKl4O X-Google-Smtp-Source: AGHT+IE8A53Y4ektcOP6sv+9R53bCUYyFWXFvUdvYdXjckk3b9uTCcJJL80qPmBhplOUZIo4feGTjr555NzmBY6LI8A= X-Received: by 2002:a05:6902:1403:b0:e8e:2368:d660 with SMTP id 3f1490d57ef6-e8e315eb0b0mr7194404276.34.1753945373435; Thu, 31 Jul 2025 00:02:53 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 31 Jul 2025 12:02:42 +0500 X-Gm-Features: Ac12FXxpgrIrNFgIG8Mm7rJMA_CCXoH0UmiEZBAQ_51uqoQpDKrxAz-ZWnNYLA8 Message-ID: Subject: Re: [PHP-DEV] [RFC] Optional Catch Block Body To: Alexandre Daubois Cc: Ayesh Karunaratne , PHP internals Content-Type: multipart/alternative; boundary="000000000000f07054063b343a93" From: 91liahim@gmail.com (Mihail Liahimov) --000000000000f07054063b343a93 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hello, Alexandre. I've heard your concerns, but I don't think this proposal will encourage other developers to ignore exceptions more often. Basically, even now, nothing can stop a developer from ignoring exceptions. He can simply leave the body of the capture block empty. And in this RFC is proposed just to allow not to write extra brackets {}. If we talk from the point of view of bad practices and applicability, then the same nullsafe operator may encourage developers to check for null less often. And this leads to problems, I personally observed this. It seems to me that the issue of bad and good practices should be the responsibility of developers. A programming language is just a tool. And there are many ways in which it can be "badly" applied. =D1=87=D1=82, 31 =D0=B8=D1=8E=D0=BB. 2025=E2=80=AF=D0=B3. =D0=B2 11:51, Ale= xandre Daubois : > > Of course, empty catch blocks are bad practice in most cases. But this > particular proposal is not intended to encourage these bad practices. I'm > just suggesting that you don't have to write an extra boiler plate at the > syntax level in situations where it's necessary. > > From what I can tell, it's very rare to have empty catch blocks, and > even more being done rightfully. I'd be very suspicious if I came > across such code. > > I think the extra boilerplate is actually a good thing, showing the > explicit intent to not catch the error. I get that the proposal is not > intended to encourage such a thing, but I agree with Ayesh: it would > definitely will. > --000000000000f07054063b343a93 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hello, Alexandre.

I've heard y= our concerns, but I don't think this proposal will encourage other deve= lopers to ignore exceptions more often. Basically, even now, nothing can st= op a developer from ignoring exceptions. He can simply leave the body of th= e capture block empty. And in this RFC is proposed just to allow not to wri= te extra brackets {}.

If we talk from the point of view of bad pract= ices and applicability, then the same nullsafe operator may encourage devel= opers to check for null less often. And this leads to problems, I personall= y observed this.

It seems to me that the issue of bad and good pract= ices should be the responsibility of developers. A programming language is = just a tool. And there are many ways in which it can be "badly" a= pplied.

=D1=87=D1=82, 31 =D0=B8=D1=8E=D0=BB. 2025= =E2=80=AF=D0=B3. =D0=B2 11:51, Alexandre Daubois <alex.daubois+php@gmail.com>:
> Of course, empty catch b= locks are bad practice in most cases. But this particular proposal is not i= ntended to encourage these bad practices. I'm just suggesting that you = don't have to write an extra boiler plate at the syntax level in situat= ions where it's necessary.

From what I can tell, it's very rare to have empty catch blocks, and even more being done rightfully. I'd be very suspicious if I came
across such code.

I think the extra boilerplate is actually a good thing, showing the
explicit intent to not catch the error. I get that the proposal is not
intended to encourage such a thing, but I agree with Ayesh: it would
definitely will.
--000000000000f07054063b343a93--