On Tue, Nov 15, 2011 at 11:50 PM, John Du Hart compwhizii@gmail.com wrote:
Right now our coding conventions manual never touches on method chaining, nor have I personally seen this practice in core. So I'm interested in
what
the rest of the community feels about adapting this practice more, and if there are trade offs I'm not aware of. Let's make an example, take this code from Abuse Filter:
$out = $this->getOutput(); $out->setPageTitle( wfMsg( 'abusefilter-examine' ) ); $out->addWikiMsg( 'abusefilter-examine-intro' );
So, instead of writing it like that, it could be written
$this->getOutput() ->setPageTitle( wfMsg( 'abusefilter-examine' ) ) ->addWikiMsg( 'abusefilter-examine-intro' );
It's just another style I've encountered on other projects and I
personally
like.
-- John Du Hart
All our (newer) JavaScript is full of this sort of syntax, although it does somehow look messier with the right-arrow than the period in jQuery. I don't see a problem with using the technique in our PHP code as well.
--HM