Hi Adam,

Adam Harvey wrote:
On 25 February 2016 at 09:40, Andrea Faulds <a...@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.

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/

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

Reply via email to