PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/libs/overloadable_php4.php

https://github.com/MrRio/wildflower
PHP | 164 lines | 68 code | 3 blank | 93 comment | 10 complexity | 3106fd5370dfefdcba547b6b1592f9a4 MD5 | raw file
Possible License(s): LGPL-2.1
  1. <?php
  2. /* SVN FILE: $Id: overloadable_php4.php 7945 2008-12-19 02:16:01Z gwoo $ */
  3. /**
  4. * Overload abstraction interface. Merges differences between PHP4 and 5.
  5. *
  6. * PHP versions 4 and 5
  7. *
  8. * CakePHP(tm) : Rapid Development Framework (http://www.cakephp.org)
  9. * Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  10. *
  11. * Licensed under The MIT License
  12. * Redistributions of files must retain the above copyright notice.
  13. *
  14. * @filesource
  15. * @copyright Copyright 2005-2008, Cake Software Foundation, Inc. (http://www.cakefoundation.org)
  16. * @link http://www.cakefoundation.org/projects/info/cakephp CakePHP(tm) Project
  17. * @package cake
  18. * @subpackage cake.cake.libs
  19. * @since CakePHP(tm) v 1.2
  20. * @version $Revision: 7945 $
  21. * @modifiedby $LastChangedBy: gwoo $
  22. * @lastmodified $Date: 2008-12-18 18:16:01 -0800 (Thu, 18 Dec 2008) $
  23. * @license http://www.opensource.org/licenses/mit-license.php The MIT License
  24. */
  25. /**
  26. * Overloadable class selector
  27. *
  28. * Load the interface class based on the version of PHP.
  29. *
  30. * @package cake
  31. * @subpackage cake.cake.libs
  32. */
  33. class Overloadable extends Object {
  34. /**
  35. * Constructor.
  36. *
  37. * @access private
  38. */
  39. function __construct() {
  40. $this->overload();
  41. parent::__construct();
  42. }
  43. /**
  44. * Overload implementation.
  45. *
  46. * @access public
  47. */
  48. function overload() {
  49. if (function_exists('overload')) {
  50. if (func_num_args() > 0) {
  51. foreach (func_get_args() as $class) {
  52. if (is_object($class)) {
  53. overload(get_class($class));
  54. } elseif (is_string($class)) {
  55. overload($class);
  56. }
  57. }
  58. } else {
  59. overload(get_class($this));
  60. }
  61. }
  62. }
  63. /**
  64. * Magic method handler.
  65. *
  66. * @param string $method Method name
  67. * @param array $params Parameters to send to method
  68. * @param mixed $return Where to store return value from method
  69. * @return boolean Success
  70. * @access private
  71. */
  72. function __call($method, $params, &$return) {
  73. if (!method_exists($this, 'call__')) {
  74. trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
  75. }
  76. $return = $this->call__($method, $params);
  77. return true;
  78. }
  79. }
  80. Overloadable::overload('Overloadable');
  81. /**
  82. * Overloadable2 class selector
  83. *
  84. * Load the interface class based on the version of PHP.
  85. *
  86. * @package cake
  87. * @subpackage cake.cake.libs
  88. */
  89. class Overloadable2 extends Object {
  90. /**
  91. * Constructor
  92. *
  93. * @access private
  94. */
  95. function __construct() {
  96. $this->overload();
  97. parent::__construct();
  98. }
  99. /**
  100. * Overload implementation.
  101. *
  102. * @access public
  103. */
  104. function overload() {
  105. if (function_exists('overload')) {
  106. if (func_num_args() > 0) {
  107. foreach (func_get_args() as $class) {
  108. if (is_object($class)) {
  109. overload(get_class($class));
  110. } elseif (is_string($class)) {
  111. overload($class);
  112. }
  113. }
  114. } else {
  115. overload(get_class($this));
  116. }
  117. }
  118. }
  119. /**
  120. * Magic method handler.
  121. *
  122. * @param string $method Method name
  123. * @param array $params Parameters to send to method
  124. * @param mixed $return Where to store return value from method
  125. * @return boolean Success
  126. * @access private
  127. */
  128. function __call($method, $params, &$return) {
  129. if (!method_exists($this, 'call__')) {
  130. trigger_error(sprintf(__('Magic method handler call__ not defined in %s', true), get_class($this)), E_USER_ERROR);
  131. }
  132. $return = $this->call__($method, $params);
  133. return true;
  134. }
  135. /**
  136. * Getter.
  137. *
  138. * @param mixed $name What to get
  139. * @param mixed $value Where to store returned value
  140. * @return boolean Success
  141. * @access private
  142. */
  143. function __get($name, &$value) {
  144. $value = $this->get__($name);
  145. return true;
  146. }
  147. /**
  148. * Setter.
  149. *
  150. * @param mixed $name What to set
  151. * @param mixed $value Value to set
  152. * @return boolean Success
  153. * @access private
  154. */
  155. function __set($name, $value) {
  156. $this->set__($name, $value);
  157. return true;
  158. }
  159. }
  160. Overloadable::overload('Overloadable2');
  161. ?>