Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:91432 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 79942 invoked from network); 26 Feb 2016 11:26:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 26 Feb 2016 11:26:05 -0000 X-Host-Fingerprint: 178.62.40.5 ajf.me Received: from [178.62.40.5] ([178.62.40.5:16315] helo=localhost.localdomain) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F9/72-55238-C4630D65 for ; Fri, 26 Feb 2016 06:26:04 -0500 Message-ID: To: internals@lists.php.net References: <97.82.11730.D8C3FC65@pb1.pair.com> Date: Fri, 26 Feb 2016 11:26:01 +0000 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.11; rv:42.0) Gecko/20100101 Firefox/42.0 SeaMonkey/2.39 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Posted-By: 178.62.40.5 Subject: Re: [PHP-DEV] Re: [RFC] Callable constructors From: ajf@ajf.me (Andrea Faulds) Hi Adam, Adam Harvey wrote: > On 25 February 2016 at 09:40, Andrea Faulds wrote: >> Instead of changing __construct to implicitly create the object it acts on >> in certain contexts, I would suggest a simpler approach: add a magic ::new() >> static method that exists on all classes (think ::class, although that is a >> constant). Foo::new() would work identically to new Foo(), and would solve >> your use case. It would be more intuitive, I think, and it avoids the >> problems of changing __construct. > > (Un?)fortunately, new() is a valid method name for userland classes in PHP 7.0. It is indeed, but that means the risk of backwards compatibility breakage is quite low. PHP 7 hasn't been out for long. Thanks! -- Andrea Faulds https://ajf.me/