On 11 August 2014 17:09, Julien Pauli <jpa...@php.net> wrote: > On Mon, Aug 11, 2014 at 12:59 PM, Ferenc Kovacs <tyr...@gmail.com> wrote: >> On Sat, Aug 9, 2014 at 12:35 PM, Tom Oram <t...@scl.co.uk> wrote: >> >>> 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: >>> >>> final class A >>> { >>> } >>> >>> $r = new ReflectionClass('A'); >>> >>> $r->defineExtendableClass('ExtendableA'); >>> >>> class MockA extends ExtendabledA >>> { >>> } >>> >>> I'm unfamiliar with the PHP codebase so I thought I'd just ask here to find >>> out if it sounds possible before diving into the code >>> >>> Thoughts? >>> >>> Regards, >>> Tom > > > Supporting this at an engine level would be harder than you think. > > We already had lots of difficulties patching > newInstanceWithoutConstructor() to support internal classes (5.6) > because they've never been designed to support creation without the > call to their constructor. > > Removing (or giving a way to remove) FINAL should be OK for userland > classes, but that will be hard to support for internal classes and > would require lots of work. Some of them could even never support it.
I don't think that it even makes sense to have this as a possibility for internal classes. tbh I doubt it makes sense to do it in userland either (class shouldn't have been declared final in the first place) but there may some testing applications that are not immediately apparent to me, as implied by the code sample in the original mail. If such a feature were to be implemented as part of reflection as suggested (I'm not a fan), not supporting internal classes would be totally acceptable IMO. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php