Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:67191 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14941 invoked from network); 29 Apr 2013 15:11:08 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Apr 2013 15:11:08 -0000 Authentication-Results: pb1.pair.com smtp.mail=johannes@schlueters.de; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=johannes@schlueters.de; sender-id=unknown Received-SPF: error (pb1.pair.com: domain schlueters.de from 217.114.211.66 cause and error) X-PHP-List-Original-Sender: johannes@schlueters.de X-Host-Fingerprint: 217.114.211.66 config.schlueters.de Received: from [217.114.211.66] ([217.114.211.66:64079] helo=config.schlueters.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 74/52-00193-A8D8E715 for ; Mon, 29 Apr 2013 11:11:08 -0400 Received: from [192.168.2.20] (ppp-88-217-80-242.dynamic.mnet-online.de [88.217.80.242]) (using TLSv1 with cipher DHE-RSA-CAMELLIA256-SHA (256/256 bits)) (Client did not present a certificate) by config.schlueters.de (Postfix) with ESMTPSA id C321E656EF; Mon, 29 Apr 2013 17:11:03 +0200 (CEST) To: Lars Strojny Cc: Julien Pauli , PHP Internals In-Reply-To: <2284A817-6E8E-44AB-BEF2-2BA1923A3BAA@strojny.net> References: <2284A817-6E8E-44AB-BEF2-2BA1923A3BAA@strojny.net> Content-Type: text/plain; charset="UTF-8" Date: Mon, 29 Apr 2013 17:12:27 +0200 Message-ID: <1367248347.2723.1918.camel@guybrush> Mime-Version: 1.0 X-Mailer: Evolution 2.30.3 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Continued try blocks From: johannes@schlueters.de (Johannes =?ISO-8859-1?Q?Schl=FCter?=) On Mon, 2013-04-29 at 08:25 +0200, Lars Strojny wrote: > Hi Julien, > > I'm still on the fence, not sure if it isn’t too opaque. > > Am 26.04.2013 um 16:41 schrieb Julien Pauli : > [...] > > One question regarding scoping: does the next statement inherit the scope of the catch block like this? > > try { > $user = $repository->findById(123); > $user->setName($name); > $em->save($user); > return true; > } catch (NotFoundException $e) { > $user = new User(); > continue; > } catch (ValidationException $e) { > $user->setName($this->stripInvalidChars($name)); > continue; > } catch (PersistenceException $e) { > return false; > } In this specific case it would have to, as PHP has function-level scoping, no block scoping. But this really like abusing exceptions ... johannes