Re: Reflection to remove final
| From: | Stas Malyshev | Date: | Tue, 12 Aug 2014 18:52:54 +0000 |
| Subject: | Re: Reflection to remove final | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-76451@lists.php.net to get a copy of this message | ||
Hi!
> I've just been looking back at the history of this previous conversation...
>
> http://marc.info/?l=php-internals&m=132673741606531&w=2
>
> as a mockist tester I'd really REALLY like to see this be possible but I
> can see the problem with the original patch modifying the actual existing
> class.
>
> One solution I propose is rather than modify it would it be possible for
> the reflection class to be able to duplicate the class with the finals
> removed so something like this could be possible:
I don't think it is a good idea. If class is marked as final, there must
be a reason why it can not be extended, and if you break that, then bad
things can happen - such as we seen in the example of abusing
unserializer for internal classes. For internal classes, it may segfault
or worse, for user classes, there can be weird undefined behavior. I
don't think it is a good idea to allow such things in core. If the class
really needs to be extended, just make it not final.
--
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/