/framework/vendor/zend/Zend/Reflection/Parameter.php

http://zoop.googlecode.com/ · PHP · 123 lines · 63 code · 9 blank · 51 comment · 11 complexity · 6cfe4def79c4345ba137cbe07bea38f0 MD5 · raw file

  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_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
  19. * @version $Id: Parameter.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /**
  22. * @category Zend
  23. * @package Zend_Reflection
  24. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  25. * @license http://framework.zend.com/license/new-bsd New BSD License
  26. */
  27. class Zend_Reflection_Parameter extends ReflectionParameter
  28. {
  29. /**
  30. * @var bool
  31. */
  32. protected $_isFromMethod = false;
  33. /**
  34. * Get declaring class reflection object
  35. *
  36. * @param string $reflectionClass Reflection class to use
  37. * @return Zend_Reflection_Class
  38. */
  39. public function getDeclaringClass($reflectionClass = 'Zend_Reflection_Class')
  40. {
  41. $phpReflection = parent::getDeclaringClass();
  42. $zendReflection = new $reflectionClass($phpReflection->getName());
  43. if (!$zendReflection instanceof Zend_Reflection_Class) {
  44. require_once 'Zend/Reflection/Exception.php';
  45. throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
  46. }
  47. unset($phpReflection);
  48. return $zendReflection;
  49. }
  50. /**
  51. * Get class reflection object
  52. *
  53. * @param string $reflectionClass Reflection class to use
  54. * @return Zend_Reflection_Class
  55. */
  56. public function getClass($reflectionClass = 'Zend_Reflection_Class')
  57. {
  58. $phpReflection = parent::getClass();
  59. if($phpReflection == null) {
  60. return null;
  61. }
  62. $zendReflection = new $reflectionClass($phpReflection->getName());
  63. if (!$zendReflection instanceof Zend_Reflection_Class) {
  64. require_once 'Zend/Reflection/Exception.php';
  65. throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend Zend_Reflection_Class');
  66. }
  67. unset($phpReflection);
  68. return $zendReflection;
  69. }
  70. /**
  71. * Get declaring function reflection object
  72. *
  73. * @param string $reflectionClass Reflection class to use
  74. * @return Zend_Reflection_Function|Zend_Reflection_Method
  75. */
  76. public function getDeclaringFunction($reflectionClass = null)
  77. {
  78. $phpReflection = parent::getDeclaringFunction();
  79. if ($phpReflection instanceof ReflectionMethod) {
  80. $baseClass = 'Zend_Reflection_Method';
  81. if (null === $reflectionClass) {
  82. $reflectionClass = $baseClass;
  83. }
  84. $zendReflection = new $reflectionClass($this->getDeclaringClass()->getName(), $phpReflection->getName());
  85. } else {
  86. $baseClass = 'Zend_Reflection_Function';
  87. if (null === $reflectionClass) {
  88. $reflectionClass = $baseClass;
  89. }
  90. $zendReflection = new $reflectionClass($phpReflection->getName());
  91. }
  92. if (!$zendReflection instanceof $baseClass) {
  93. require_once 'Zend/Reflection/Exception.php';
  94. throw new Zend_Reflection_Exception('Invalid reflection class provided; must extend ' . $baseClass);
  95. }
  96. unset($phpReflection);
  97. return $zendReflection;
  98. }
  99. /**
  100. * Get parameter type
  101. *
  102. * @return string
  103. */
  104. public function getType()
  105. {
  106. if ($docblock = $this->getDeclaringFunction()->getDocblock()) {
  107. $params = $docblock->getTags('param');
  108. if (isset($params[$this->getPosition()])) {
  109. return $params[$this->getPosition()]->getType();
  110. }
  111. }
  112. return null;
  113. }
  114. }