Added the zend framework 2 library, the path is specified in line no.26 in zend_modul...
[openemr.git] / interface / modules / zend_modules / library / Zend / Server / Reflection / ReflectionClass.php
blob146d64c307cee6c3499a0832d110ffec50c6f649
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Server\Reflection;
12 use ReflectionClass as PhpReflectionClass;
14 /**
15 * Class/Object reflection
17 * Proxies calls to a ReflectionClass object, and decorates getMethods() by
18 * creating its own list of {@link Zend\Server\Reflection\ReflectionMethod}s.
20 class ReflectionClass
22 /**
23 * Optional configuration parameters; accessible via {@link __get} and
24 * {@link __set()}
25 * @var array
27 protected $config = array();
29 /**
30 * Array of {@link \Zend\Server\Reflection\Method}s
31 * @var array
33 protected $methods = array();
35 /**
36 * Namespace
37 * @var string
39 protected $namespace = null;
41 /**
42 * ReflectionClass object
43 * @var PhpReflectionClass
45 protected $reflection;
47 /**
48 * Constructor
50 * Create array of dispatchable methods, each a
51 * {@link Zend\Server\Reflection\ReflectionMethod}. Sets reflection object property.
53 * @param PhpReflectionClass $reflection
54 * @param string $namespace
55 * @param mixed $argv
57 public function __construct(PhpReflectionClass $reflection, $namespace = null, $argv = false)
59 $this->reflection = $reflection;
60 $this->setNamespace($namespace);
62 foreach ($reflection->getMethods() as $method) {
63 // Don't aggregate magic methods
64 if ('__' == substr($method->getName(), 0, 2)) {
65 continue;
68 if ($method->isPublic()) {
69 // Get signatures and description
70 $this->methods[] = new ReflectionMethod($this, $method, $this->getNamespace(), $argv);
75 /**
76 * Proxy reflection calls
78 * @param string $method
79 * @param array $args
80 * @throws Exception\BadMethodCallException
81 * @return mixed
83 public function __call($method, $args)
85 if (method_exists($this->reflection, $method)) {
86 return call_user_func_array(array($this->reflection, $method), $args);
89 throw new Exception\BadMethodCallException('Invalid reflection method');
92 /**
93 * Retrieve configuration parameters
95 * Values are retrieved by key from {@link $config}. Returns null if no
96 * value found.
98 * @param string $key
99 * @return mixed
101 public function __get($key)
103 if (isset($this->config[$key])) {
104 return $this->config[$key];
107 return null;
111 * Set configuration parameters
113 * Values are stored by $key in {@link $config}.
115 * @param string $key
116 * @param mixed $value
117 * @return void
119 public function __set($key, $value)
121 $this->config[$key] = $value;
125 * Return array of dispatchable {@link \Zend\Server\Reflection\ReflectionMethod}s.
127 * @access public
128 * @return array
130 public function getMethods()
132 return $this->methods;
136 * Get namespace for this class
138 * @return string
140 public function getNamespace()
142 return $this->namespace;
146 * Set namespace for this class
148 * @param string $namespace
149 * @throws Exception\InvalidArgumentException
150 * @return void
152 public function setNamespace($namespace)
154 if (empty($namespace)) {
155 $this->namespace = '';
156 return;
159 if (!is_string($namespace) || !preg_match('/[a-z0-9_\.]+/i', $namespace)) {
160 throw new Exception\InvalidArgumentException('Invalid namespace');
163 $this->namespace = $namespace;
167 * Wakeup from serialization
169 * Reflection needs explicit instantiation to work correctly. Re-instantiate
170 * reflection object on wakeup.
172 * @return void
174 public function __wakeup()
176 $this->reflection = new PhpReflectionClass($this->getName());