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.
16 * @package Zend_Reflection
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
24 * @package Zend_Reflection
25 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
26 * @license http://framework.zend.com/license/new-bsd New BSD License
28 class Zend_Reflection_Parameter
extends ReflectionParameter
33 protected $_isFromMethod = false;
36 * Get declaring class reflection object
38 * @param string $reflectionClass Reflection class to use
39 * @return Zend_Reflection_Class
41 public function getDeclaringClass($reflectionClass = 'Zend_Reflection_Class')
43 $phpReflection = parent
::getDeclaringClass();
44 $zendReflection = new $reflectionClass($phpReflection->getName());
45 if (!$zendReflection instanceof Zend_Reflection_Class
) {
46 require_once 'Zend/Reflection/Exception.php';
47 throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
49 unset($phpReflection);
50 return $zendReflection;
54 * Get class reflection object
56 * @param string $reflectionClass Reflection class to use
57 * @return Zend_Reflection_Class
59 public function getClass($reflectionClass = 'Zend_Reflection_Class')
61 $phpReflection = parent
::getClass();
62 if($phpReflection == null) {
66 $zendReflection = new $reflectionClass($phpReflection->getName());
67 if (!$zendReflection instanceof Zend_Reflection_Class
) {
68 require_once 'Zend/Reflection/Exception.php';
69 throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
71 unset($phpReflection);
72 return $zendReflection;
76 * Get declaring function reflection object
78 * @param string $reflectionClass Reflection class to use
79 * @return Zend_Reflection_Function|Zend_Reflection_Method
81 public function getDeclaringFunction($reflectionClass = null)
83 $phpReflection = parent
::getDeclaringFunction();
84 if ($phpReflection instanceof ReflectionMethod
) {
85 $baseClass = 'Zend_Reflection_Method';
86 if (null === $reflectionClass) {
87 $reflectionClass = $baseClass;
89 $zendReflection = new $reflectionClass($this->getDeclaringClass()->getName(), $phpReflection->getName());
91 $baseClass = 'Zend_Reflection_Function';
92 if (null === $reflectionClass) {
93 $reflectionClass = $baseClass;
95 $zendReflection = new $reflectionClass($phpReflection->getName());
97 if (!$zendReflection instanceof $baseClass) {
98 require_once 'Zend/Reflection/Exception.php';
99 throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend ' . $baseClass);
101 unset($phpReflection);
102 return $zendReflection;
110 public function getType()
112 if ($docblock = $this->getDeclaringFunction()->getDocblock()) {
113 $params = $docblock->getTags('param');
115 if (isset($params[$this->getPosition()])) {
116 return $params[$this->getPosition()]->getType();