[ Index ] |
PHP Cross Reference of moodle-2.8 |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * Zend Framework 4 * 5 * LICENSE 6 * 7 * This source file is subject to the new BSD license that is bundled 8 * with this package in the file LICENSE.txt. 9 * It is also available through the world-wide-web at this URL: 10 * http://framework.zend.com/license/new-bsd 11 * If you did not receive a copy of the license and are unable to 12 * obtain it through the world-wide-web, please send an email 13 * to [email protected] so we can send you a copy immediately. 14 * 15 * @category Zend 16 * @package Zend_Server 17 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 18 * @license http://framework.zend.com/license/new-bsd New BSD License 19 */ 20 21 /** 22 * Zend_Server_Reflection_Method 23 */ 24 require_once 'Zend/Server/Reflection/Method.php'; 25 26 /** 27 * Class/Object reflection 28 * 29 * Proxies calls to a ReflectionClass object, and decorates getMethods() by 30 * creating its own list of {@link Zend_Server_Reflection_Method}s. 31 * 32 * @category Zend 33 * @package Zend_Server 34 * @subpackage Reflection 35 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) 36 * @license http://framework.zend.com/license/new-bsd New BSD License 37 * @version $Id$ 38 */ 39 class Zend_Server_Reflection_Class 40 { 41 /** 42 * Optional configuration parameters; accessible via {@link __get} and 43 * {@link __set()} 44 * @var array 45 */ 46 protected $_config = array(); 47 48 /** 49 * Array of {@link Zend_Server_Reflection_Method}s 50 * @var array 51 */ 52 protected $_methods = array(); 53 54 /** 55 * Namespace 56 * @var string 57 */ 58 protected $_namespace = null; 59 60 /** 61 * ReflectionClass object 62 * @var ReflectionClass 63 */ 64 protected $_reflection; 65 66 /** 67 * Constructor 68 * 69 * Create array of dispatchable methods, each a 70 * {@link Zend_Server_Reflection_Method}. Sets reflection object property. 71 * 72 * @param ReflectionClass $reflection 73 * @param string $namespace 74 * @param mixed $argv 75 * @return void 76 */ 77 public function __construct(ReflectionClass $reflection, $namespace = null, $argv = false) 78 { 79 $this->_reflection = $reflection; 80 $this->setNamespace($namespace); 81 82 foreach ($reflection->getMethods() as $method) { 83 // Don't aggregate magic methods 84 if ('__' == substr($method->getName(), 0, 2)) { 85 continue; 86 } 87 88 if ($method->isPublic()) { 89 // Get signatures and description 90 $this->_methods[] = new Zend_Server_Reflection_Method($this, $method, $this->getNamespace(), $argv); 91 } 92 } 93 } 94 95 /** 96 * Proxy reflection calls 97 * 98 * @param string $method 99 * @param array $args 100 * @return mixed 101 */ 102 public function __call($method, $args) 103 { 104 if (method_exists($this->_reflection, $method)) { 105 return call_user_func_array(array($this->_reflection, $method), $args); 106 } 107 108 require_once 'Zend/Server/Reflection/Exception.php'; 109 throw new Zend_Server_Reflection_Exception('Invalid reflection method'); 110 } 111 112 /** 113 * Retrieve configuration parameters 114 * 115 * Values are retrieved by key from {@link $_config}. Returns null if no 116 * value found. 117 * 118 * @param string $key 119 * @return mixed 120 */ 121 public function __get($key) 122 { 123 if (isset($this->_config[$key])) { 124 return $this->_config[$key]; 125 } 126 127 return null; 128 } 129 130 /** 131 * Set configuration parameters 132 * 133 * Values are stored by $key in {@link $_config}. 134 * 135 * @param string $key 136 * @param mixed $value 137 * @return void 138 */ 139 public function __set($key, $value) 140 { 141 $this->_config[$key] = $value; 142 } 143 144 /** 145 * Return array of dispatchable {@link Zend_Server_Reflection_Method}s. 146 * 147 * @access public 148 * @return array 149 */ 150 public function getMethods() 151 { 152 return $this->_methods; 153 } 154 155 /** 156 * Get namespace for this class 157 * 158 * @return string 159 */ 160 public function getNamespace() 161 { 162 return $this->_namespace; 163 } 164 165 /** 166 * Set namespace for this class 167 * 168 * @param string $namespace 169 * @return void 170 */ 171 public function setNamespace($namespace) 172 { 173 if (empty($namespace)) { 174 $this->_namespace = ''; 175 return; 176 } 177 178 if (!is_string($namespace) || !preg_match('/[a-z0-9_\.]+/i', $namespace)) { 179 require_once 'Zend/Server/Reflection/Exception.php'; 180 throw new Zend_Server_Reflection_Exception('Invalid namespace'); 181 } 182 183 $this->_namespace = $namespace; 184 } 185 186 /** 187 * Wakeup from serialization 188 * 189 * Reflection needs explicit instantiation to work correctly. Re-instantiate 190 * reflection object on wakeup. 191 * 192 * @return void 193 */ 194 public function __wakeup() 195 { 196 $this->_reflection = new ReflectionClass($this->getName()); 197 } 198 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Fri Nov 28 20:29:05 2014 | Cross-referenced by PHPXref 0.7.1 |