Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:66242 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 91099 invoked from network); 26 Feb 2013 12:58:11 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2013 12:58:11 -0000 Authentication-Results: pb1.pair.com header.from=addw@phcomp.co.uk; sender-id=permerror Authentication-Results: pb1.pair.com smtp.mail=addw@phcomp.co.uk; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain phcomp.co.uk designates 78.32.209.33 as permitted sender) X-PHP-List-Original-Sender: addw@phcomp.co.uk X-Host-Fingerprint: 78.32.209.33 freshmint.phcomp.co.uk Received: from [78.32.209.33] ([78.32.209.33:58661] helo=mint.phcomp.co.uk) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 67/71-16132-161BC215 for ; Tue, 26 Feb 2013 07:58:10 -0500 Received: from addw by mint.phcomp.co.uk with local (Exim 4.72) (envelope-from ) id 1UAK6f-0006Su-8s for internals@lists.php.net; Tue, 26 Feb 2013 12:58:05 +0000 Date: Tue, 26 Feb 2013 12:58:05 +0000 To: PHP internals Message-ID: <20130226125805.GT3832@phcomp.co.uk> Mail-Followup-To: PHP internals References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Organization: Parliament Hill Computers Ltd User-Agent: Mutt/1.5.20 (2009-12-10) Subject: Re: [PHP-DEV] Allow (...)->foo() expressions not only for `new` From: addw@phcomp.co.uk (Alain Williams) On Tue, Feb 26, 2013 at 01:35:47PM +0100, Sebastian Krebs wrote: > 2013/2/26 Lazare Inepologlou > > > Hello Nikita, > > > > 2013/2/25 Nikita Popov > > > > > Hi internals! > > > > > > PHP 5.4 added support for expressions of the kind (new Foo)->bar(), (new > > > Foo)->bar and (new Foo)['bar']. > > > > > > > > I guess it must have been discussed, but Is there any technical reason or > > conflict that prevents us from having something like new Foo->bar(), > > without the extra parenthesis? > > > > It could mean "new (Foo->bar())", which in this case is invalid, but there > are other cases, where this problem is more obvious > > if ($foo) { > $bar = 'Classname'; > } else { > $bar = new BarClass; > } > > new $bar->baz(); // "(new $bar)->baz()" or "new ($bar->baz())"? The precedence is quite clear, it would be the first, see: http://www.php.net/manual/en/language.operators.precedence.php However, I do agree that it might be a bit confusing. What is disappointing is that I cannot go: ($f = new Foo)->bar(); That does not suffer from a lack of clarity on intent. -- Alain Williams Linux/GNU Consultant - Mail systems, Web sites, Networking, Programmer, IT Lecturer. +44 (0) 787 668 0256 http://www.phcomp.co.uk/ Parliament Hill Computers Ltd. Registration Information: http://www.phcomp.co.uk/contact.php #include