On Sat, Jul 26, 2014 at 1:26 AM, Stas Malyshev <smalys...@sugarcrm.com>
wrote:

> Hi!
>
> > yeah, that would work ofc, but as these libs seems to have instanitate
> > arbitrary classes, that would require either generating files on the fly
> > and including them or simply evaling them, but of those are a  bit
> > dirtier than using Reflection for the same job.
>
> True but that's what phpunit, etc. are doing for mocks anyway, aren't they?


nope, some mock frameworks do that (afair atoum for example) but
phpunit(phpunit-mock-objects to be more precise) was using the serialize
trick and newInstanceWithoutConstructor() (
https://github.com/sebastianbergmann/phpunit-mock-objects/blob/42f29d650744fd7ce785e7a4dd3598a09b0bfd2b/src/Framework/MockObject/Generator.php#L273),
and now they switched to Instantiator from Ocramius(he also participated in
this thread) which also uses the unserialize trick and
newInstanceWithoutConstructor() (
https://github.com/Ocramius/Instantiator/blob/86e562799ceb87316fcb70e151551f47dd215a0f/src/Instantiator/Instantiator.php#L80
).


>


> > true, but it can also be used to argue for loosening the restriction,
> > why restrict something from Reflection, which is already possible from
> > simple class extension.
>
> I agree, probably makes sense to allow it if you can do it anyway.
> Reflection is not something you can trigger without explicit codding
> (unlike O: thing) so it's fine with me.
>

yeah, exactly.


>
> > a nice thing from OOP POV and also will cause problems if/when we
> > introduce a reflection method removing final from classes/methods (this
> > was already proposed not that long ago with a working patch but was
> > turned down because other reasons).
>
> That probably wouldn't be a good idea, especially for internal classes.
>

I should have left out this argument, because that has it's own can of
worms, but if anybody interested in the original proposal:
http://grokbase.com/t/php/php-internals/121gmxkz1c/php-dev-reflection-to-remove-final
I wasn't proposing merging this in my mail, just argued that if this
proposal ever merged, that would either require fixing up the finals
anyways or it would be possible to trigger similar segfaults and stuff.

-- 
Ferenc Kovács
@Tyr43l - http://tyrael.hu

Reply via email to