Re: Re: [RFC] Callable constructors
| From: | Nikita Nefedov | Date: | Fri, 26 Feb 2016 11:47:19 +0000 |
| Subject: | Re: Re: [RFC] Callable constructors | ||
| References: | 1 2 3 4 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91435@lists.php.net to get a copy of this message | ||
On Fri, 26 Feb 2016 14:28:19 +0300, Andrea Faulds <ajf@ajf.me> wrote:
Hi Rowan, Rowan Collins wrote:Hey Andrea, This would still not solve Dan's problem though. Which is representingOn 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 would serve such a limited purpose.Yeah, I do wonder if ::new would really be worth it.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 of that for constructors could work (ReflectionClass::getConstructorClosure() ?). Thanks.
new Class as a serializeable callable.
I really think ::new() makes the most sense here (and looks quite alright unlike Class::__construct()).
Although making a special case for new ... is pretty simple, I too have felt the need for callable constructors plenty of times, that would be useful.