|
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 license@zend.com 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 * Parameter Reflection |
|
23 * |
|
24 * Decorates a ReflectionParameter to allow setting the parameter type |
|
25 * |
|
26 * @category Zend |
|
27 * @package Zend_Server |
|
28 * @subpackage Reflection |
|
29 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com) |
|
30 * @license http://framework.zend.com/license/new-bsd New BSD License |
|
31 * @version $Id: Parameter.php 20096 2010-01-06 02:05:09Z bkarwin $ |
|
32 */ |
|
33 class Zend_Server_Reflection_Parameter |
|
34 { |
|
35 /** |
|
36 * @var ReflectionParameter |
|
37 */ |
|
38 protected $_reflection; |
|
39 |
|
40 /** |
|
41 * Parameter position |
|
42 * @var int |
|
43 */ |
|
44 protected $_position; |
|
45 |
|
46 /** |
|
47 * Parameter type |
|
48 * @var string |
|
49 */ |
|
50 protected $_type; |
|
51 |
|
52 /** |
|
53 * Parameter description |
|
54 * @var string |
|
55 */ |
|
56 protected $_description; |
|
57 |
|
58 /** |
|
59 * Constructor |
|
60 * |
|
61 * @param ReflectionParameter $r |
|
62 * @param string $type Parameter type |
|
63 * @param string $description Parameter description |
|
64 */ |
|
65 public function __construct(ReflectionParameter $r, $type = 'mixed', $description = '') |
|
66 { |
|
67 $this->_reflection = $r; |
|
68 $this->setType($type); |
|
69 $this->setDescription($description); |
|
70 } |
|
71 |
|
72 /** |
|
73 * Proxy reflection calls |
|
74 * |
|
75 * @param string $method |
|
76 * @param array $args |
|
77 * @return mixed |
|
78 */ |
|
79 public function __call($method, $args) |
|
80 { |
|
81 if (method_exists($this->_reflection, $method)) { |
|
82 return call_user_func_array(array($this->_reflection, $method), $args); |
|
83 } |
|
84 |
|
85 require_once 'Zend/Server/Reflection/Exception.php'; |
|
86 throw new Zend_Server_Reflection_Exception('Invalid reflection method'); |
|
87 } |
|
88 |
|
89 /** |
|
90 * Retrieve parameter type |
|
91 * |
|
92 * @return string |
|
93 */ |
|
94 public function getType() |
|
95 { |
|
96 return $this->_type; |
|
97 } |
|
98 |
|
99 /** |
|
100 * Set parameter type |
|
101 * |
|
102 * @param string|null $type |
|
103 * @return void |
|
104 */ |
|
105 public function setType($type) |
|
106 { |
|
107 if (!is_string($type) && (null !== $type)) { |
|
108 require_once 'Zend/Server/Reflection/Exception.php'; |
|
109 throw new Zend_Server_Reflection_Exception('Invalid parameter type'); |
|
110 } |
|
111 |
|
112 $this->_type = $type; |
|
113 } |
|
114 |
|
115 /** |
|
116 * Retrieve parameter description |
|
117 * |
|
118 * @return string |
|
119 */ |
|
120 public function getDescription() |
|
121 { |
|
122 return $this->_description; |
|
123 } |
|
124 |
|
125 /** |
|
126 * Set parameter description |
|
127 * |
|
128 * @param string|null $description |
|
129 * @return void |
|
130 */ |
|
131 public function setDescription($description) |
|
132 { |
|
133 if (!is_string($description) && (null !== $description)) { |
|
134 require_once 'Zend/Server/Reflection/Exception.php'; |
|
135 throw new Zend_Server_Reflection_Exception('Invalid parameter description'); |
|
136 } |
|
137 |
|
138 $this->_description = $description; |
|
139 } |
|
140 |
|
141 /** |
|
142 * Set parameter position |
|
143 * |
|
144 * @param int $index |
|
145 * @return void |
|
146 */ |
|
147 public function setPosition($index) |
|
148 { |
|
149 $this->_position = (int) $index; |
|
150 } |
|
151 |
|
152 /** |
|
153 * Return parameter position |
|
154 * |
|
155 * @return int |
|
156 */ |
|
157 public function getPosition() |
|
158 { |
|
159 return $this->_position; |
|
160 } |
|
161 } |