3 * Overload abstraction interface. Merges differences between PHP4 and 5.
7 * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
8 * Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
10 * Licensed under The MIT License
11 * Redistributions of files must retain the above copyright notice.
13 * @copyright Copyright 2005-2010, Cake Software Foundation, Inc. (http://cakefoundation.org)
14 * @link http://cakephp.org CakePHP(tm) Project
16 * @subpackage cake.cake.libs
17 * @since CakePHP(tm) v 1.2
18 * @license MIT License (http://www.opensource.org/licenses/mit-license.php)
22 * Overloadable class selector
24 * Load the interface class based on the version of PHP.
27 * @subpackage cake.cake.libs
29 class Overloadable
extends Object {
36 function __construct() {
38 parent
::__construct();
42 * Overload implementation.
47 if (function_exists('overload')) {
48 if (func_num_args() > 0) {
49 foreach (func_get_args() as $class) {
50 if (is_object($class)) {
51 overload(get_class($class));
52 } elseif (is_string($class)) {
57 overload(get_class($this));
63 * Magic method handler.
65 * @param string $method Method name
66 * @param array $params Parameters to send to method
67 * @param mixed $return Where to store return value from method
68 * @return boolean Success
71 function __call($method, $params, &$return) {
72 if (!method_exists($this, 'call__')) {
73 trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR
);
75 $return = $this->call__($method, $params);
79 Overloadable
::overload('Overloadable');
82 * Overloadable2 class selector
84 * Load the interface class based on the version of PHP.
87 * @subpackage cake.cake.libs
89 class Overloadable2
extends Object {
96 function __construct() {
98 parent
::__construct();
102 * Overload implementation.
106 function overload() {
107 if (function_exists('overload')) {
108 if (func_num_args() > 0) {
109 foreach (func_get_args() as $class) {
110 if (is_object($class)) {
111 overload(get_class($class));
112 } elseif (is_string($class)) {
117 overload(get_class($this));
123 * Magic method handler.
125 * @param string $method Method name
126 * @param array $params Parameters to send to method
127 * @param mixed $return Where to store return value from method
128 * @return boolean Success
131 function __call($method, $params, &$return) {
132 if (!method_exists($this, 'call__')) {
133 trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR
);
135 $return = $this->call__($method, $params);
142 * @param mixed $name What to get
143 * @param mixed $value Where to store returned value
144 * @return boolean Success
147 function __get($name, &$value) {
148 $value = $this->get__($name);
155 * @param mixed $name What to set
156 * @param mixed $value Value to set
157 * @return boolean Success
160 function __set($name, $value) {
161 $this->set__($name, $value);
165 Overloadable
::overload('Overloadable2');