File indexing completed on 2024-12-22 05:37:01
0001 <?php 0002 /** 0003 * Zend Framework 0004 * 0005 * LICENSE 0006 * 0007 * This source file is subject to the new BSD license that is bundled 0008 * with this package in the file LICENSE.txt. 0009 * It is also available through the world-wide-web at this URL: 0010 * http://framework.zend.com/license/new-bsd 0011 * If you did not receive a copy of the license and are unable to 0012 * obtain it through the world-wide-web, please send an email 0013 * to license@zend.com so we can send you a copy immediately. 0014 * 0015 * @category Zend 0016 * @package Zend_Server 0017 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0018 * @license http://framework.zend.com/license/new-bsd New BSD License 0019 */ 0020 0021 /** 0022 * Parameter Reflection 0023 * 0024 * Decorates a ReflectionParameter to allow setting the parameter type 0025 * 0026 * @category Zend 0027 * @package Zend_Server 0028 * @subpackage Reflection 0029 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com) 0030 * @license http://framework.zend.com/license/new-bsd New BSD License 0031 * @version $Id$ 0032 */ 0033 class Zend_Server_Reflection_Parameter 0034 { 0035 /** 0036 * @var ReflectionParameter 0037 */ 0038 protected $_reflection; 0039 0040 /** 0041 * Parameter position 0042 * @var int 0043 */ 0044 protected $_position; 0045 0046 /** 0047 * Parameter type 0048 * @var string 0049 */ 0050 protected $_type; 0051 0052 /** 0053 * Parameter description 0054 * @var string 0055 */ 0056 protected $_description; 0057 0058 /** 0059 * Constructor 0060 * 0061 * @param ReflectionParameter $r 0062 * @param string $type Parameter type 0063 * @param string $description Parameter description 0064 */ 0065 public function __construct(ReflectionParameter $r, $type = 'mixed', $description = '') 0066 { 0067 $this->_reflection = $r; 0068 $this->setType($type); 0069 $this->setDescription($description); 0070 } 0071 0072 /** 0073 * Proxy reflection calls 0074 * 0075 * @param string $method 0076 * @param array $args 0077 * @return mixed 0078 */ 0079 public function __call($method, $args) 0080 { 0081 if (method_exists($this->_reflection, $method)) { 0082 return call_user_func_array(array($this->_reflection, $method), $args); 0083 } 0084 0085 // require_once 'Zend/Server/Reflection/Exception.php'; 0086 throw new Zend_Server_Reflection_Exception('Invalid reflection method'); 0087 } 0088 0089 /** 0090 * Retrieve parameter type 0091 * 0092 * @return string 0093 */ 0094 public function getType() 0095 { 0096 return $this->_type; 0097 } 0098 0099 /** 0100 * Set parameter type 0101 * 0102 * @param string|null $type 0103 * @return void 0104 */ 0105 public function setType($type) 0106 { 0107 if (!is_string($type) && (null !== $type)) { 0108 // require_once 'Zend/Server/Reflection/Exception.php'; 0109 throw new Zend_Server_Reflection_Exception('Invalid parameter type'); 0110 } 0111 0112 $this->_type = $type; 0113 } 0114 0115 /** 0116 * Retrieve parameter description 0117 * 0118 * @return string 0119 */ 0120 public function getDescription() 0121 { 0122 return $this->_description; 0123 } 0124 0125 /** 0126 * Set parameter description 0127 * 0128 * @param string|null $description 0129 * @return void 0130 */ 0131 public function setDescription($description) 0132 { 0133 if (!is_string($description) && (null !== $description)) { 0134 // require_once 'Zend/Server/Reflection/Exception.php'; 0135 throw new Zend_Server_Reflection_Exception('Invalid parameter description'); 0136 } 0137 0138 $this->_description = $description; 0139 } 0140 0141 /** 0142 * Set parameter position 0143 * 0144 * @param int $index 0145 * @return void 0146 */ 0147 public function setPosition($index) 0148 { 0149 $this->_position = (int) $index; 0150 } 0151 0152 /** 0153 * Return parameter position 0154 * 0155 * @return int 0156 */ 0157 public function getPosition() 0158 { 0159 return $this->_position; 0160 } 0161 }