On Fri, 26 Feb 2016 14:28:19 +0300, Andrea Faulds <a...@ajf.me> 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 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.

Hey Andrea,

This would still not solve Dan's problem though. Which is representing `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.

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to