“__class magic method” (mediating references to class names

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
gidireich
Forum Newbie
Posts: 2
Joined: Thu Nov 11, 2010 8:41 pm

“__class magic method” (mediating references to class names

Post 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
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

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

Post 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.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
Post Reply