diff --git a/cake/libs/overloadable_php4.php b/cake/libs/overloadable_php4.php index d3646a874..14417aa5e 100644 --- a/cake/libs/overloadable_php4.php +++ b/cake/libs/overloadable_php4.php @@ -59,12 +59,56 @@ class Overloadable extends Object { } function __call($method, $params, &$return) { - // if(!method_exists('__call__')) Error! + if(!method_exists($this, '__call__')) { + trigger_error('Magic method handler __call__ not defined in ' . get_class($this), E_USER_ERROR); + } $return = $this->__call__($method, $params); return true; } } - Overloadable::overload('Overloadable'); +class Overloadable2 extends Object { + + function __construct() { + $this->overload(); + parent::__construct(); + } + + function overload() { + if (function_exists('overload')) { + if (func_num_args() > 0) { + foreach (func_get_args() as $class) { + if (is_object($class)) { + overload(get_class($class)); + } elseif (is_string($class)) { + overload($class); + } + } + } else { + overload(get_class($this)); + } + } + } + + function __call($method, $params, &$return) { + if(!method_exists($this, '__call__')) { + trigger_error('Magic method handler __call__ not defined in ' . get_class($this), E_USER_ERROR); + } + $return = $this->__call__($method, $params); + return true; + } + + function __get($name, &$value) { + $value = $this->__get__($name); + return true; + } + + function __set($name, $value) { + $this->__set__($name, $value); + return true; + } +} +Overloadable::overload('Overloadable2'); + ?> \ No newline at end of file diff --git a/cake/libs/overloadable_php5.php b/cake/libs/overloadable_php5.php index 196601a4f..dfd56ec3e 100644 --- a/cake/libs/overloadable_php5.php +++ b/cake/libs/overloadable_php5.php @@ -40,9 +40,31 @@ class Overloadable extends Object { function overload() { } function __call($method, $params) { - // if(!method_exists('__call__')) Error! + if(!method_exists($this, '__call__')) { + trigger_error('Magic method handler __call__ not defined in ' . get_class($this), E_USER_ERROR); + } return $this->__call__($method, $params); } } +class Overloadable2 extends Object { + + function overload() { } + + function __call($method, $params) { + if(!method_exists($this, '__call__')) { + trigger_error('Magic method handler __call__ not defined in ' . get_class($this), E_USER_ERROR); + } + return $this->__call__($method, $params); + } + + function __get($name) { + return $this->get__($name); + } + + function __set($name, $value) { + return $this->set__($name, $value); + } +} + ?> \ No newline at end of file