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
10 namespace Zend\Server\Reflection
;
13 * Parameter Reflection
15 * Decorates a ReflectionParameter to allow setting the parameter type
17 class ReflectionParameter
20 * @var \ReflectionParameter
22 protected $reflection;
37 * Parameter description
40 protected $description;
45 * @param \ReflectionParameter $r
46 * @param string $type Parameter type
47 * @param string $description Parameter description
49 public function __construct(\ReflectionParameter
$r, $type = 'mixed', $description = '')
51 $this->reflection
= $r;
52 $this->setType($type);
53 $this->setDescription($description);
57 * Proxy reflection calls
59 * @param string $method
61 * @throws Exception\BadMethodCallException
64 public function __call($method, $args)
66 if (method_exists($this->reflection
, $method)) {
67 return call_user_func_array(array($this->reflection
, $method), $args);
70 throw new Exception\
BadMethodCallException('Invalid reflection method');
74 * Retrieve parameter type
78 public function getType()
86 * @param string|null $type
87 * @throws Exception\InvalidArgumentException
90 public function setType($type)
92 if (!is_string($type) && (null !== $type)) {
93 throw new Exception\
InvalidArgumentException('Invalid parameter type');
100 * Retrieve parameter description
104 public function getDescription()
106 return $this->description
;
110 * Set parameter description
112 * @param string|null $description
113 * @throws Exception\InvalidArgumentException
116 public function setDescription($description)
118 if (!is_string($description) && (null !== $description)) {
119 throw new Exception\
InvalidArgumentException('Invalid parameter description');
122 $this->description
= $description;
126 * Set parameter position
131 public function setPosition($index)
133 $this->position
= (int) $index;
137 * Return parameter position
141 public function getPosition()
143 return $this->position
;