mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-18 18:46:17 +00:00
Adding Overloadable2 interface for get() and set() magic methods
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@3957 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
e955f3fd65
commit
d4af73c2a6
2 changed files with 69 additions and 3 deletions
|
@ -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');
|
||||
|
||||
?>
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
Loading…
Add table
Reference in a new issue