composer package updates
[openemr.git] / vendor / zendframework / zend-server / src / Reflection / ReflectionParameter.php
blob94fa9a1e75be03e8df5554e6266cf839afe33b8b
1 <?php
2 /**
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
6 */
8 namespace Zend\Server\Reflection;
10 /**
11 * Parameter Reflection
13 * Decorates a ReflectionParameter to allow setting the parameter type
15 class ReflectionParameter
17 /**
18 * @var \ReflectionParameter
20 protected $reflection;
22 /**
23 * Parameter position
24 * @var int
26 protected $position;
28 /**
29 * Parameter type
30 * @var string
32 protected $type;
34 /**
35 * Parameter description
36 * @var string
38 protected $description;
40 /**
41 * Constructor
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);
54 /**
55 * Proxy reflection calls
57 * @param string $method
58 * @param array $args
59 * @throws Exception\BadMethodCallException
60 * @return mixed
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');
71 /**
72 * Retrieve parameter type
74 * @return string
76 public function getType()
78 return $this->type;
81 /**
82 * Set parameter type
84 * @param string|null $type
85 * @throws Exception\InvalidArgumentException
86 * @return void
88 public function setType($type)
90 if (! is_string($type) && (null !== $type)) {
91 throw new Exception\InvalidArgumentException('Invalid parameter type');
94 $this->type = $type;
97 /**
98 * Retrieve parameter description
100 * @return string
102 public function getDescription()
104 return $this->description;
108 * Set parameter description
110 * @param string|null $description
111 * @throws Exception\InvalidArgumentException
112 * @return void
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
126 * @param int $index
127 * @return void
129 public function setPosition($index)
131 $this->position = (int) $index;
135 * Return parameter position
137 * @return int
139 public function getPosition()
141 return $this->position;