Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:46832 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 77222 invoked from network); 20 Jan 2010 04:08:17 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Jan 2010 04:08:17 -0000 Authentication-Results: pb1.pair.com smtp.mail=danielc@analysisandsolutions.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=danielc@analysisandsolutions.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain analysisandsolutions.com from 166.84.1.72 cause and error) X-PHP-List-Original-Sender: danielc@analysisandsolutions.com X-Host-Fingerprint: 166.84.1.72 mail1.panix.com Received: from [166.84.1.72] ([166.84.1.72:64703] helo=mail1.panix.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/BC-29385-0B1865B4 for ; Tue, 19 Jan 2010 23:08:17 -0500 Received: from panix5.panix.com (panix5.panix.com [166.84.1.5]) by mail1.panix.com (Postfix) with ESMTP id 190621F093 for ; Tue, 19 Jan 2010 23:08:14 -0500 (EST) Received: by panix5.panix.com (Postfix, from userid 14662) id 0473524251; Tue, 19 Jan 2010 23:08:13 -0500 (EST) Date: Tue, 19 Jan 2010 23:08:13 -0500 To: PHP Internals List Message-ID: <20100120040813.GA20133@panix.com> References: <4B54FC87.8070106@zend.com> <4B55EE56.8040104@lerdorf.com> <4B55FA44.1060601@zend.com> <20100119190836.GA17124@panix.com> <4B5608B2.8050308@zend.com> <20100119195724.GA5597@panix.com> <4B561191.2040700@zend.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4B561191.2040700@zend.com> User-Agent: Mutt/1.5.18 (2008-05-17) Subject: Re: [PHP-DEV] function call chaining From: danielc@analysisandsolutions.com (Daniel Convissor) Hi Stas: On Tue, Jan 19, 2010 at 12:09:53PM -0800, Stanislav Malyshev wrote: > > $oop = $eep->oop(); > $ork = $oop->ork(); > $ah = $ork->ah(); > $ah2 = $ah->ah(); > > where it instantly becomes crystal clear! :) Yep, that's lousy code. Variables should be named for the classes they represent. $eep = new eep; $eep->oop(); $decorator = $eep->ork(); $decorator->ah(); $decorator->ah(); // Output, of course, is "I love you". // What do you mean you've never seen The Jetsons?! Now it's clear that oop() is a method of eep while ork returns a decorator object that contains the ah() method. No guess work involved. If everything is chained, it's a pain to figure out such basic workings. I'll leave it at this. Thanks, --Dan -- T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y data intensive web and database programming http://www.AnalysisAndSolutions.com/ 4015 7th Ave #4, Brooklyn NY 11232 v: 718-854-0335 f: 718-854-0409