Reflection for methods implemented with the __call method

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Reflection for methods implemented with the __call method

Gordon Schmidt

while trying to implement a generic wrapper layer for my webserver model classes i realized that methods implemented within the __call method can't be called from the server.
Reflection is used within the setClass, when you try to add classes to your server. So i patched the Zend_Server_Reflection_Class to allow wrapper classes to provide additional methods for Reflection.

It's working prety well, so i'd like to share this patch:

In order to share additional methods, your wrapper class have to implement a static function __getMethods, that could look like this:
final static public function __getMethods(ReflectionClass $reflection, $namespace = null, $argv = false)
    return Zend_Server_Reflection::reflectClass(self::$_wrappedClass, $argv, $namespace)->getMethods();

It's pretty useful, if you like to do ACL and caching in different layers wrapped around the real functionality of your server.

Actually i don't like patching libraries. But most zend servers use a static reflection class, you cannot replace with any option.

I would really appreciate, if a feature like this would be integrated deeper within php, so declaring hidden methods would be also possible for php's ReflectionClass and get_class_methods.

I'd would be nice, if you could post me some feedback on this topic