Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50682 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79297 invoked from network); 29 Nov 2010 07:52:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2010 07:52:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=softfail; sender-id=softfail Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=softfail Received-SPF: softfail (pb1.pair.com: domain zend.com does not designate 188.65.64.9 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 188.65.64.9 homemail.n-home.ru Received: from [188.65.64.9] ([188.65.64.9:49602] helo=mailgw.nnz-home.ru) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A6/70-10413-EBB53FC4 for ; Mon, 29 Nov 2010 02:52:31 -0500 Received: from localhost (unknown [127.0.0.1]) by mailgw.nnz-home.ru (Postfix) with ESMTP id 1573B2845B; Mon, 29 Nov 2010 10:46:03 +0300 (MSK) X-Virus-Scanned: amavisd-new at mailgw.nnz-home.ru Received: from mailgw.nnz-home.ru ([127.0.0.1]) by localhost (mailgw.nnz-home.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CWZXDoitFX8y; Mon, 29 Nov 2010 10:46:02 +0300 (MSK) Received: from ws.home (unknown [10.83.32.11]) by mailgw.nnz-home.ru (Postfix) with ESMTP id CCD052845A; Mon, 29 Nov 2010 10:46:02 +0300 (MSK) Message-ID: <4CF35BBA.3040006@zend.com> Date: Mon, 29 Nov 2010 10:52:26 +0300 User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.12) Gecko/20101103 Fedora/1.0-0.33.b2pre.fc14 Lightning/1.0b3pre Thunderbird/3.1.6 MIME-Version: 1.0 To: Felipe Pena CC: internals References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] [RFC] new foo()->bar() From: dmitry@zend.com (Dmitry Stogov) Hi Felipe, I'm wondered it works out of the box with so small patches :) However, both patches introduce new parser conflicts and it would be grate to avoid them. Also the patches need to be checked for memory leaks in case of exceptions thrown from constructor and chained function(s). It also probably makes sense to add array deference chaining e.g. new Foo()[] (just for language consistency). Thanks. Dmitry. On 11/26/2010 10:36 PM, Felipe Pena wrote: > Hi all, > I'm here again to presents another proposal, which adds support for > instantiating a class and calling its methods and accessing its properties > on same command. > > Example: > > > class bar { > public $x = 'PHP'; > } > > class foo extends bar { > public function bar() { > return $this; > } > } > > var_dump(new foo()->bar()->x); // string(3) "PHP" > > ?> > > Other examples which describes the feature at > http://wiki.php.net/rfc/instance-method-call > > Thoughts? >