Re: [RFC] Array Dereferencing

From: Date: Tue, 08 Jun 2010 13:09:16 +0000
Subject: Re: [RFC] Array Dereferencing
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-48686@lists.php.net to get a copy of this message
On 08/06/2010, at 12.41, Johannes Schlüter wrote: > On Tue, 2010-06-08 at 12:23 +0200, Jacob Oettinger wrote: >> Would it be equally simple to allow the syntax below? >> >> $result = new ResultMaker()->getIt(); > > does this mean > > $result = new (ResultMaker()->getIt()); > > or > > $result = (new ResultMaker())->getIt(); > > I assume the later, but that is non-obvious as we allow > > $result = new $class(); Yes the later. I do not see how the above makes it non-obvious. As I see it the new operator will always instantiate the class name that comes after it. The name can be given as either a literal class name, or as a string variable or as a string variable in an array. It can not be given as a function or method that returns a string. Regardless, it was the direct calling of a function (or invokable) returned from a function I think was a good idea for consistency. Jacob

« previous php.internals (#48686) next »