Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56732 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 11389 invoked from network); 3 Dec 2011 09:42:23 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 3 Dec 2011 09:42:23 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@sugarcrm.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@sugarcrm.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain sugarcrm.com designates 207.97.245.163 as permitted sender) X-PHP-List-Original-Sender: smalyshev@sugarcrm.com X-Host-Fingerprint: 207.97.245.163 smtp163.iad.emailsrvr.com Linux 2.6 Received: from [207.97.245.163] ([207.97.245.163:47667] helo=smtp163.iad.emailsrvr.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/71-27819-EFEE9DE4 for ; Sat, 03 Dec 2011 04:42:22 -0500 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp46.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 4D93EE868B; Sat, 3 Dec 2011 04:42:19 -0500 (EST) X-Virus-Scanned: OK Received: by smtp46.relay.iad1a.emailsrvr.com (Authenticated sender: smalyshev-AT-sugarcrm.com) with ESMTPSA id C3EAEE82B0; Sat, 3 Dec 2011 04:42:18 -0500 (EST) Message-ID: <4ED9EEFA.9090504@sugarcrm.com> Date: Sat, 03 Dec 2011 01:42:18 -0800 Organization: SugarCRM User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 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> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] 5.4's New De-referencing plus assignment From: smalyshev@sugarcrm.com (Stas Malyshev) Hi! > 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. Personally, I think the latter code is much better than the former. It makes clear what is created, where, and what the condition is doing, and doesn't require my internal parser to work too hard :) On the other hand, I don't see a real reason why -> shouldn't be able to be applied to any expression. Yes, sometimes it would be (or seem to me) bad style, so what? It's not like bad style is impossible now ;) -- Stanislav Malyshev, Software Architect SugarCRM: http://www.sugarcrm.com/ (408)454-6900 ext. 227