Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52501 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 94775 invoked from network); 22 May 2011 22:05:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 May 2011 22:05:52 -0000 X-Host-Fingerprint: 208.107.178.23 host-23-178-107-208.midco.net Date: Sun, 22 May 2011 18:05:51 -0400 Received: from [208.107.178.23] ([208.107.178.23:18457] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id D7/F0-23260-EB889DD4 for ; Sun, 22 May 2011 18:05:51 -0400 Message-ID: To: internals@lists.php.net References: User-Agent: slrn/pre1.0.0-18 (Linux) X-Posted-By: 208.107.178.23 Subject: Re: [PHP-DEV] Constructor object instance dereferentiation From: weierophinney@php.net (Matthew Weier O'Phinney) On 2011-05-22, Ferenc Kovacs wrote: > --bcaec52be62721150704a3d8f926 > Content-Type: text/plain; charset=UTF-8 > > On Sun, May 22, 2011 at 6:18 AM, dukeofgaming wrote: > > I was wondering if object dereferentiation after constructor call is > > something that has been discussed already. This is, being able to do > > something like: > > > > new MyClass()-> setSomething(); > > > > Instead of: > > > > $var = new MyClass(); > > $var-> setSomething(); > > it was already discussion, Felipe created an RFC and a patch, the responses > was all positive, so I think if nobody changed their mind, we could move > this from Under Discussion to Accepted/Implemented > as I said before, it would be in good pair with the already implemented > array dereferencing (https://wiki.php.net/rfc/functionarraydereferencing) > > http://marc.info/?l=php-internals&m=129080024516125&w=2 > https://wiki.php.net/rfc/instance-method-call One thing not on the RFC that I'm curious about: if the class defines __invoke(), would the following work? new MyClass()(); That would be particularly useful for implementing helper systems, which are quite often one-off use cases. -- 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