Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56725 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 41699 invoked from network); 2 Dec 2011 16:56:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2011 16:56:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=rasmus@lerdorf.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=rasmus@lerdorf.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain lerdorf.com from 209.85.210.170 cause and error) X-PHP-List-Original-Sender: rasmus@lerdorf.com X-Host-Fingerprint: 209.85.210.170 mail-iy0-f170.google.com Received: from [209.85.210.170] ([209.85.210.170:40300] helo=mail-iy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 80/B3-16911-E4309DE4 for ; Fri, 02 Dec 2011 11:56:47 -0500 Received: by iaeh11 with SMTP id h11so1595470iae.29 for ; Fri, 02 Dec 2011 08:56:44 -0800 (PST) Received: by 10.42.117.193 with SMTP id u1mr15412382icq.24.1322845004402; Fri, 02 Dec 2011 08:56:44 -0800 (PST) Received: from [192.168.200.5] (c-50-131-44-225.hsd1.ca.comcast.net. [50.131.44.225]) by mx.google.com with ESMTPS id p16sm36671621ibk.6.2011.12.02.08.56.42 (version=SSLv3 cipher=OTHER); Fri, 02 Dec 2011 08:56:43 -0800 (PST) Message-ID: <4ED90349.5090308@lerdorf.com> Date: Fri, 02 Dec 2011 08:56:41 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:8.0) Gecko/20111124 Thunderbird/8.0 MIME-Version: 1.0 To: Matthew Weier O'Phinney CC: internals@lists.php.net References: <4ED6713D.2050009@ralphschindler.com> <4ED67DCB.5090102@ralphschindler.com> <4ED68940.3050502@ralphschindler.com> <90D867E2-E6FB-481D-B57C-911E5FE6A418@gmail.com> <4ED7BAC2.20805@ralphschindler.com> <9B.03.16911.EB109DE4@pb1.pair.com> In-Reply-To: <9B.03.16911.EB109DE4@pb1.pair.com> X-Enigmail-Version: 1.4a1pre Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: rasmus@lerdorf.com (Rasmus Lerdorf) On 12/02/2011 08:50 AM, Matthew Weier O'Phinney wrote: > if (!(($validator = new SomeValidator())->isValid($value))) { > // Validation failed, get messages... > $view->assign('errors' => $validator->getMessages()); > return $view->render('error'); > } > // validation passed, do something... > > Yes, this could be written as follows: > > $validator = new SomeValidator(); > if (!$validator->isValid($value)) { > // ... > } > // ... > > However, I can see some folks not really wanting that variable > declaration if they won't be using it outside the conditional. But $validator is still going to be defined regardless of the return value of isValid() so it is going to be set outside the conditional. -Rasmus