On 10 January 2021 01:24:38 GMT+00:00, "G. P. B." <george.bany...@gmail.com> 
wrote:
>Moreover, asymmetric visibility does not prevent mutating an object by
>calling the constructor once again as follows:
>$obj->__construct(...$args);


That's pretty trivial to work around: mark the constructor private and provide 
one or more public static methods that call it. That's actually a pretty common 
and useful design in its own right.

It's also something that could probably be banned at the language level. I seem 
to remember it being discussed before, but the details aren't quite trivial 
because you need to allow parent::__construct etc. I'd rather spend the time to 
work out those details than design the rest of the language around it being 
possible, if it's really that much of an issue.

Regards,

-- 
Rowan Tommins
[IMSoP]

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

Reply via email to