Re: Explicit constructor call and polymorphic dispatch
| From: | Wes | Date: | Fri, 13 Jan 2017 07:24:35 +0000 |
| Subject: | Re: Explicit constructor call and polymorphic dispatch | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97739@lists.php.net to get a copy of this message | ||
>
> I am baffled that this (still) works:
>
__clone was special cased in 5.x, but special case was removed in 7.0
means that previously you couldn't do publicly $obj->__clone(); now you can
and, yes, it's as dangerous as it looks
however, the special case was removed for a reason that i'm sure is a good
one, and i'm certain the same good reason is also valid for __construct
the only reason for prohibiting explicit __construct calls is that it makes
> PHP objects mutable
then don't call it explicitly, exactly like you wouldn't use reflection to
call private methods