3 * @see https://github.com/zendframework/zend-server for the canonical source repository
4 * @copyright Copyright (c) 2005-2018 Zend Technologies USA Inc. (https://www.zend.com)
5 * @license https://github.com/zendframework/zend-server/blob/master/LICENSE.md New BSD License
8 namespace Zend\Server\Reflection
;
11 * Parameter Reflection
13 * Decorates a ReflectionParameter to allow setting the parameter type
15 class ReflectionParameter
18 * @var \ReflectionParameter
20 protected $reflection;
35 * Parameter description
38 protected $description;
43 * @param \ReflectionParameter $r
44 * @param string $type Parameter type
45 * @param string $description Parameter description
47 public function __construct(\ReflectionParameter
$r, $type = 'mixed', $description = '')
49 $this->reflection
= $r;
50 $this->setType($type);
51 $this->setDescription($description);
55 * Proxy reflection calls
57 * @param string $method
59 * @throws Exception\BadMethodCallException
62 public function __call($method, $args)
64 if (method_exists($this->reflection
, $method)) {
65 return call_user_func_array([$this->reflection
, $method], $args);
68 throw new Exception\
BadMethodCallException('Invalid reflection method');
72 * Retrieve parameter type
76 public function getType()
84 * @param string|null $type
85 * @throws Exception\InvalidArgumentException
88 public function setType($type)
90 if (! is_string($type) && (null !== $type)) {
91 throw new Exception\
InvalidArgumentException('Invalid parameter type');
98 * Retrieve parameter description
102 public function getDescription()
104 return $this->description
;
108 * Set parameter description
110 * @param string|null $description
111 * @throws Exception\InvalidArgumentException
114 public function setDescription($description)
116 if (! is_string($description) && (null !== $description)) {
117 throw new Exception\
InvalidArgumentException('Invalid parameter description');
120 $this->description
= $description;
124 * Set parameter position
129 public function setPosition($index)
131 $this->position
= (int) $index;
135 * Return parameter position
139 public function getPosition()
141 return $this->position
;