mardi 21 juillet 2020

php, refreshing ReflectionClass after dynamic change

I'm trying to build a tool that add/remove methods for me in a class, basically saving me the time to type some standard methods I use in my framework.

However, it seems to me that the getMethods method of the ReflectionClass uses some sort of cache, because if I call getMethods once, then change the methods dynamically (for instance replacing the class file with another one with the same class name but different methods), then call getMethods again, it doesn't take into account my dynamic changes.

I tried sleep, but it was obviously not that.

I was wondering if there is a way (but I'm afraid there is not) in php to "refresh" the ReflectionClass, so that it can "reflect" on the actual content rather than on some sort of cache.

As a work around, I can rely on tokens, but that requires a bit more work than just using the Reflection classes, so it would be great if I could "reset" the Reflection cache somehow.





Aucun commentaire:

Enregistrer un commentaire