Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

Cannot extend ReflectionMethod #409

Closed
sirsnyder opened this issue Jan 15, 2015 · 3 comments
Closed

Cannot extend ReflectionMethod #409

sirsnyder opened this issue Jan 15, 2015 · 3 comments

Comments

@sirsnyder
Copy link
Collaborator

Hello Joe,

\Thread::extend(\ReflectionClass::class);

works like a charm! However

\Thread::extend(\ReflectionMethod::class);

throws an RuntimeException "cannot extend class ReflectionMethod, it already extends ReflectionFunctionAbstract". So I tried to extend ReflectionFunctionAbstract, but ReflectionFunctionAbstract is a trait and can't be extended.

\Thread::extend(\ReflectionFunctionAbstract::class);

cannot extend trait ReflectionFunctionAbstract

Shouldn't it be possible to extend ReflectionMethod, cause ReflectionFunctionAbstract is just a trait and no parent class of ReflectionMethod?

Thanks and keep up the good work!

OS: Win7 x64
php 5.6.4 x64, pthreads 2.0.10

@sirsnyder
Copy link
Collaborator Author

I've checked ReflectionClass::isTrait(), it's false

var_dump((new \ReflectionClass(\ReflectionFunctionAbstract::class))->isTrait());

@krakjoe
Copy link
Owner

krakjoe commented Jan 16, 2015

Thanks for report ...

On a side note, this is not likely to do what you think it will.

There is no automatic way to tell at runtime if an internal class will behave itself after it has been extended.

It is likely that a class with a create_object handler set will not work, but it's not always the case.

Threaded::extend is intended for user land classes really, but you are free to mess about with internal classes.

@sirsnyder
Copy link
Collaborator Author

Thx for the explanation, I will keep that in mind. Problem is, a ReflectionClass instance as class member must not be serialized/unseralized, otherwise it's broken.

http://php.net/manual/en/class.reflectionclass.php#106472

Extending ReflectionClass seems to help in this particular case(will observe the behavior of the Reflection* classes).

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants