Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-27 Thread Rowan Collins
On 26/02/2016 11:28, Andrea Faulds wrote: Then we could add to that a special case for constructors: - Callable::forConstructor(string $class_name) Oh, that's quite a clean solution, I like that. Heck, no need for Callable, we already have ->getClosure() in Reflection. A modified version

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-27 Thread Rowan Collins
On 26/02/2016 11:47, Nikita Nefedov wrote: Then we could add to that a special case for constructors: - Callable::forConstructor(string $class_name) Oh, that's quite a clean solution, I like that. Heck, no need for Callable, we already have ->getClosure() in Reflection. A modified version

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-26 Thread Nikita Nefedov
On Fri, 26 Feb 2016 14:28:19 +0300, Andrea Faulds wrote: Hi Rowan, Rowan Collins wrote: On 25/02/2016 17:40, Andrea Faulds wrote: Snipped for brevity, but I agree with your sentiment here. Making __construct more magic seems like an imperfect solution to this. I'm not sure

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-26 Thread Andrea Faulds
Hi Rowan, Rowan Collins wrote: On 25/02/2016 17:40, Andrea Faulds wrote: Snipped for brevity, but I agree with your sentiment here. Making __construct more magic seems like an imperfect solution to this. I'm not sure making a new magic method (new, __new, etc) is much better though, since it

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-26 Thread 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

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-25 Thread Rowan Collins
On 25/02/2016 17:40, Andrea Faulds wrote: Dan Ackroyd wrote: I've written a small RFC to make it possible to call constructors of objects as a callable, rather than only being able to call them through the 'new' language construct. https://wiki.php.net/rfc/callableconstructors While I like

Re: [PHP-DEV] Re: [RFC] Callable constructors

2016-02-25 Thread Adam Harvey
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

[PHP-DEV] Re: [RFC] Callable constructors

2016-02-25 Thread Andrea Faulds
Hi Dan, Dan Ackroyd wrote: I've written a small RFC to make it possible to call constructors of objects as a callable, rather than only being able to call them through the 'new' language construct. https://wiki.php.net/rfc/callableconstructors While I like the concept, I dislike the