Re: Re: [RFC] Callable constructors

From: Date: Thu, 25 Feb 2016 18:17:38 +0000
Subject: Re: Re: [RFC] Callable constructors
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-91414@lists.php.net to get a copy of this message
On 25 February 2016 at 09:40, Andrea Faulds <ajf@ajf.me> 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. Adam

« previous php.internals (#91414) next »