PageRenderTime 45ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 1ms

/lib/zend/Zend/Server/Reflection/Parameter.php

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