I\'m using WordPress as a CMS, and I want to extend one of its classes without having to inherit from another class; i.e. I simply want to \"add\" more methods to that class
An updated way for 2014 that copes with scope.
public function __call($method, $arguments) {
return call_user_func_array(Closure::bind($this->$method, $this, get_called_class()), $arguments);
}
Eg:
class stdObject {
public function __call($method, $arguments) {
return call_user_func_array(Closure::bind($this->$method, $this, get_called_class()), $arguments);
}
}
$obj = new stdObject();
$obj->test = function() {
echo "" . print_r($this, true) . "
";
};
$obj->test();