Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56726 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 43886 invoked from network); 2 Dec 2011 17:05:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Dec 2011 17:05:11 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:36509] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 75/24-16911-54509DE4 for ; Fri, 02 Dec 2011 12:05:10 -0500 Received: by bkcjm19 with SMTP id jm19so2285565bkc.29 for ; Fri, 02 Dec 2011 09:05:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type:content-transfer-encoding; bh=MEGi4KVIA3o9EMiQlvtfTDMM/baP1Io8RQ05Hs1Eadk=; b=pbvEArb5S9YikI1pLC5eJeIfhRKTsacKTn0GeMcjmggfliqr/w5o5GUJm2P/o0LzCb 2inKOq3P86C4Oz9XRii1/zq5Fx/W9g8sVFlsKHjWNLZWC4ks+tTb4DJv0vtKTt1WoHpN rsm0YPi4fNo/ACzdGZjqRT3FR4jq2HLV040a4= Received: by 10.204.13.70 with SMTP id b6mr11580862bka.78.1322845507019; Fri, 02 Dec 2011 09:05:07 -0800 (PST) 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@alliantinternet.com> <011701ccb113$2bdcfe20$8396fa60$@alliantinternet.com> In-Reply-To: <011701ccb113$2bdcfe20$8396fa60$@alliantinternet.com> Mime-Version: 1.0 (1.0) Date: Fri, 2 Dec 2011 12:05:07 -0500 Message-ID: <-1440206264013697810@unknownmsgid> To: Dmitri Snytkine Cc: "Matthew Weier O'Phinney" , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: will.fitch@gmail.com (Will Fitch) That variable is used for getting error messages. Sent from my iPad On Dec 2, 2011, at 11:56 AM, Dmitri Snytkine wrote: > IT would probably be even more convenient to just say > if( (new Validator())->isValid($value) ){ > > } > > No reason to just temporaraly assign $validator. > > > > Dmitri Snytkine > Web Developer > Ultra Logistics, Inc. > Phone: (888) 220-4640 x 2097 > Fax: (888) 795-6642 > E-Mail: dsnytkine@ultralogistics.com > Web: www.ultralogistics.com > > "A Top 100 Logistics I.T. Provider in 2011" > > > -----Original Message----- > From: Matthew Weier O'Phinney [mailto:weierophinney@php.net] > Sent: Friday, December 02, 2011 11:50 AM > To: internals@lists.php.net > Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment > > On 2011-12-01, Anthony Ferrara wrote: >> On Thu, Dec 1, 2011 at 12:34 PM, Ralph Schindler >> wrote: > >>> needs to somehow guarantee that all methods of the type $foo will retur= n >>> $this. =C3=82 (BTW, this is not an argument for my feature as much as i= ts an >>> argument as much as its one for "if we're going to do something, why no= t > do >>> it correctly in the first place".) =C3=82 The correct path here, IMO, w= ould > be to >>> simply carry the expression result (since we're using '(' expr ')' out > and >>> allow dereferencing on whatever comes out of it. >>> >> >> I would argue though that your syntax is completely possible today: >> >> $foo =3D new Foo; >> $foo->bar(); >> >> What's the reason to put that in a single line? Aside from terseness, >> is there any other benefit? With the new dereference, one benefit is >> that no variable is populated when none is needed. But in your case, >> you need both variables... > > Here's another example. > > We have validator classes. Typically, you call isValid() to see if a > value validates. If it does, you have no more use for the validator. If > it _doesn't_, however, you'll want to get the error messages. I could > see the following as being a nice, succinct way to use validators: > > if (!(($validator =3D new SomeValidator())->isValid($value))) { > // Validation failed, get messages... > $view->assign('errors' =3D> $validator->getMessages()); > return $view->render('error'); > } > // validation passed, do something... > > Yes, this could be written as follows: > > $validator =3D 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. > > -- > Matthew Weier O'Phinney > Project Lead | matthew@zend.com > Zend Framework | http://framework.zend.com/ > PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >