Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91588 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 72576 invoked from network); 9 Mar 2016 13:30:29 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 9 Mar 2016 13:30:29 -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.217.173 as permitted sender) X-PHP-List-Original-Sender: ocramius@gmail.com X-Host-Fingerprint: 209.85.217.173 mail-lb0-f173.google.com Received: from [209.85.217.173] ([209.85.217.173:33267] helo=mail-lb0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 9B/73-53667-27520E65 for ; Wed, 09 Mar 2016 08:30:26 -0500 Received: by mail-lb0-f173.google.com with SMTP id k15so65797799lbg.0 for ; Wed, 09 Mar 2016 05:30:26 -0800 (PST) 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=ITOgqcnJrtImMBIlxzxGGKV++HO7EGrMzl5VPC0BjtA=; b=dxLhpEBj2PiAz1SxoSynAWw+yALH1ggoiz7L1SXBgwrDxY5PzumlW7cmOLtJaSOxdL nwHxJg1/uF1kQ2HWGnNrfkt1l2V3j+D85DABZFyBGt2SLa8PdvJ+LkqjTHkMKSmtrsHK Nw4LgGT/RItLGStSBt6ZJB/6n/8XEbPTWITAQ8wuBdtGepr2k82Pg8fKf3TsaWGhjb5s wNX2hrtvUACG/6bnYyAkvld9y3KquiyTwRDpdv0XaxKnJMvPioJzVeRTqvKYPEEdM8gO E5lv+br9bgUtHTUGYs/A9VOGVDXdMA3wjN0fMMUDl0V5o68BZXbiA6624N+fcQtXR9O+ CjuQ== 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=ITOgqcnJrtImMBIlxzxGGKV++HO7EGrMzl5VPC0BjtA=; b=IIO+QQhKwczMmbCnMjr14AINQ/2+cQzr2BdKWgwdJ4nEdok+kxO+n5+vWRXlHYKkv9 wXanImRtAPVvdijt8ehaAPjBlHt5EBo+0HqxXOmXR/+u29NVNphe47YA6jZgpO/mC0Tv rlOv1sQo40hxVon/lVZJp5WBGG+kZxpj54pAIyeeMuljoTAYP/ZGIqJa+7bu8gGhRPQ0 Ezp4EGdQkwnB7f5WWnctaULvpMGdVCAbMtaon5ZZNC0yZPobyU20cUdY7N393Hv6jur1 bXsEreINV4bqfW7m2RejlLPdsC8sIv+TDwsA2aN0uD/ybJxId/ssTM/zvsZrah9/APnf 4+uQ== X-Gm-Message-State: AD7BkJKxIls7rndqgrmVAQE/eEDl6Akt2hkoKYVgsvbphg9FxQ+wyDR3ZjK1ibtLjdDxuN0VQIBaxhevu9s2dg== X-Received: by 10.25.17.65 with SMTP id g62mr9858534lfi.52.1457530223044; Wed, 09 Mar 2016 05:30:23 -0800 (PST) MIME-Version: 1.0 Received: by 10.112.59.167 with HTTP; Wed, 9 Mar 2016 05:30:03 -0800 (PST) In-Reply-To: References: Date: Wed, 9 Mar 2016 14:30:03 +0100 Message-ID: To: Pierrick Charron Cc: Derick Rethans , PHP internals , =?UTF-8?B?QnJvbmlzxYJhdyBCaWHFgmVr?= Content-Type: multipart/alternative; boundary=001a114071b031beb4052d9db33a Subject: Re: [PHP-DEV] [RFC Discussion] Catching multiple exception types From: ocramius@gmail.com (Marco Pivetta) --001a114071b031beb4052d9db33a Content-Type: text/plain; charset=UTF-8 On 9 March 2016 at 14:24, Pierrick Charron wrote: > > The thing I don't like about this approach is that I have to read the code > and double check to make sure that the catch statement call the same method. > For the amount of work that needs to be done in the Engine (see the patch > attached to the RFC) this is far more readable and it is clear that the > code to handle those 3 exceptions is the exact same one. And if the code of > handleFailure is small you can even put it at this single place. > > public function stuff() > { > try { > $this->willFail(); > } catch (FirstException | SecondException | ThirdException $e) { > $this->handleFailure($e); > } > } > > I'd still have to write 3 test cases anyway: no real amount of code-savings there. I still think the first solution is as readable as the one you proposed there. The change in the PHP engine might be trivial, but the syntax change from a userland perspective is a mess (tooling, pretty much anything that relies on an AST parser needs changes there). Do not underestimate language changes as a php-core only issue. Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/ --001a114071b031beb4052d9db33a--