Page 1 of 1

“__class magic method” (mediating references to class names

Posted: Thu Nov 11, 2010 8:52 pm
by gidireich
You can redirect calls to some properties/functions by using __get, __call.

Is there a way to do it for classes?

I would like to convert all mentions of some_class_name in the code to, MY_VERSION_some_class_name (not only for one class, it's a pattern).

This would be easy if methods / properties were the target of this renaming policy.

Can you think of a way to do it for classes in PHP?

Thanks

Re: “__class magic method” (mediating references to class na

Posted: Thu Nov 11, 2010 10:39 pm
by s.dot
you can use method_exists() with the class name and method name to check if that method exists, or use string manipulation to convert the call to your naming convention

I would stay away from using magic methods like this though. You might change the functionality or other developers won't know where the "magic" is happening.