Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92411 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21713 invoked from network); 18 Apr 2016 13:41:20 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 18 Apr 2016 13:41:20 -0000 Authentication-Results: pb1.pair.com smtp.mail=ocramius@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ocramius@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.43 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.215.43 mail-lf0-f43.google.com Received: from [209.85.215.43] ([209.85.215.43:33346] helo=mail-lf0-f43.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/17-11975-DF3E4175 for ; Mon, 18 Apr 2016 09:41:18 -0400 Received: by mail-lf0-f43.google.com with SMTP id e190so217174477lfe.0 for ; Mon, 18 Apr 2016 06:41:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=F7KUzTCEclkaUz3B257R05/0fXRDSIxhSfBAOoelL2U=; b=0befu4gspLUImYixe5WSfxktwIdGU645ZGUi42heVC6NZT0IFYZwkL2VyUADrbBT0z 74t9hdRu4aBzI1VcK+WUGF8mk7bG+mW5Ruxtkz/fmwqaLum+4SnWwXhOIn93UmdPz4n4 uKHEuisn8DddedeWFoA+cMzz42PyvSDKVmj91Py6uyOaPjqLU+WedZzmGgL7GxwssHsG VO8FPs68gr/m3a1PxSDAD7qSXUPMTK7QrJfsQHTuxDP/eDp7nay5ICRaDHjArsfYk3Eq o7VGttbMh8fohNiMXXbzRLs7IZesLOxSX6MuTcQHgWd+888lrA+a71GYvA47YqOjgHg/ Lp4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=F7KUzTCEclkaUz3B257R05/0fXRDSIxhSfBAOoelL2U=; b=BRxSjD44SxkR7G/fqXVGuNsa2HYf5dX5XoqvP3diK63AvK7bUSURDJ1eKjz8ZxkqdV SBVMQT1fTKr9pj3L5AwzraTmKOnSaFwqIkdvhPSEVp8utLLPxNmwUonKzxxYOfA+6g5x dz8ic5LrdtPo/cTVSHE5tVAr+o1XZx5ctaEyOaz1olOGXzNQbfNdeMydYEFfS8AnU14u DBgnbQLKSj3AHHBFReoWOuXk5DZlLiNRtHJSRnEWp6Y0TvvYW5wodlHzk+HCM70WbxBz UL1jaCzIrjbpcLDBjI9Z9ugqFGAnrxB8zvTv6eB1SOEcgmxHq1HpERWczPPtjdc008ME yUgA== X-Gm-Message-State: AOPr4FV62waKdWPf1Fm+BThk8LTvJ847SIYTIKG+J24MZ7T0DXTi1Fa8Rk+0GZl0argfaYsw2F/BeUS9VeGOhA== X-Received: by 10.112.171.161 with SMTP id av1mr14448221lbc.82.1460986874030; Mon, 18 Apr 2016 06:41:14 -0700 (PDT) MIME-Version: 1.0 Received: by 10.112.126.67 with HTTP; Mon, 18 Apr 2016 06:40:54 -0700 (PDT) In-Reply-To: References: Date: Mon, 18 Apr 2016 15:40:54 +0200 Message-ID: To: Dan Ackroyd Cc: =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= , PHP internals Content-Type: multipart/alternative; boundary=001a11c36fa2a5f5730530c283df Subject: Re: [PHP-DEV] [VOTE] Catching Multiple Exception Types From: ocramius@gmail.com (Marco Pivetta) --001a11c36fa2a5f5730530c283df Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Heya, I voted "NO" due to previous discussion. TL;DR: this is FAR off the 80/20 use-case for a language syntax change. C&P from my answer elsewhere: The following typical example is something REALLY rare, and requiring a parser change for it seems excessive: try { // ... } catch (InvalidArgumentException $e) { // same handling } catch (PDOException $e) { // same handling } catch (BadMethodCallException $e) { // same handling } These 3 exceptions usually result in separate handling anyway. If same handling is needed, you can as usual extract a private method (if you are in a class) and deal with it there: try { // ... } catch (InvalidArgumentException $e) { $this->sameHandling($e); } catch (PDOException $e) { $this->sameHandling($e); } catch (BadMethodCallException $e) { $this->sameHandling($e); } private function sameHandling(Throwable $caught) { // same handling } Still, even in this case, I'd flag it up in a code review, as same handling for 3 different exception types generally (not always) means something is really wrong. So we are building a feature for a 1% case that, while simple to implement at parser-level in PHP, requires changes in all userland libraries that do parsing or rely on the AST. Cheers, Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ On 18 April 2016 at 01:08, Dan Ackroyd wrote: > I voted yes. > > It's really not that common that I have to do stuff in exception > handling, when I do need to do some clearing up, or checking to see if > the operation that threw the exception needs to be re-tried, having to > repeat that code in all of the catch statements that need it, is just > nasty duplication. > > Although it's a small change, having this is a very nice small > improvement that doesn't break anyone's existing code. > > Thanks for putting it forward. > > cheers > Dan > > > On 17 April 2016 at 17:51, Bronis=C5=82aw Bia=C5=82ek = wrote: > > Hi Internals, > > > > We've opened the vote on https://wiki.php.net/rfc/multiple-catch > > Voting will end on 2015-05-01 > > > > -- > > Regards, > > Bronis=C5=82aw Bia=C5=82ek. > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a11c36fa2a5f5730530c283df--