PageRenderTime 46ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/cake/libs/overloadable_php4.php

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