In PHP, if a static attribute is defined in the parent class, it cannot be overridden in a child class. But I\'m wondering if there\'s any way around this.
I\'m try
Classic example of why using statics as globals (functions in this case) is a bad idea no matter the language.
The most robust method is to create multiple implementation sub classes of an abstract base "Action" class.
Then to try and remove some of the annoyance of instantiating an instance of the class just to call it's methods, you can wrap it in a factory of some sort.
For example:
abstract class AbstractAction {
public abstract function do();
}
class FooAction extends AbstractAction {
public function do() {
echo "Do Foo Action";
}
}
class BarAction extends AbstractAction {
public function do() {
echo "Do Bar Action";
}
}
Then create a factory to "aid" in instantiation of the function
class ActionFactory {
public static function get($action_name) {
//... return AbstractAction instance here
}
}
Then use it as:
ActionFactory::get('foo')->do();