/framework/vendor/zend/Zend/Reflection/Docblock/Tag/Param.php

http://zoop.googlecode.com/ · PHP · 93 lines · 35 code · 11 blank · 47 comment · 5 complexity · 2ea05305f902062b0f2fc144c209ccb9 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: Param.php 20096 2010-01-06 02:05:09Z bkarwin $
  20. */
  21. /** Zend_Reflection_Docblock_Tag */
  22. require_once 'Zend/Reflection/Docblock/Tag.php';
  23. /**
  24. * @category Zend
  25. * @package Zend_Reflection
  26. * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
  27. * @license http://framework.zend.com/license/new-bsd New BSD License
  28. */
  29. class Zend_Reflection_Docblock_Tag_Param extends Zend_Reflection_Docblock_Tag
  30. {
  31. /**
  32. * @var string
  33. */
  34. protected $_type = null;
  35. /**
  36. * @var string
  37. */
  38. protected $_variableName = null;
  39. /**
  40. * Constructor
  41. *
  42. * @param string $tagDocblockLine
  43. */
  44. public function __construct($tagDocblockLine)
  45. {
  46. $matches = array();
  47. if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
  48. require_once 'Zend/Reflection/Exception.php';
  49. throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
  50. }
  51. if ($matches[1] != 'param') {
  52. require_once 'Zend/Reflection/Exception.php';
  53. throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid @param tag');
  54. }
  55. $this->_name = 'param';
  56. $this->_type = $matches[2];
  57. if (isset($matches[3])) {
  58. $this->_variableName = $matches[3];
  59. }
  60. if (isset($matches[4])) {
  61. $this->_description = preg_replace('#\s+#', ' ', $matches[4]);
  62. }
  63. }
  64. /**
  65. * Get parameter variable type
  66. *
  67. * @return string
  68. */
  69. public function getType()
  70. {
  71. return $this->_type;
  72. }
  73. /**
  74. * Get parameter name
  75. *
  76. * @return string
  77. */
  78. public function getVariableName()
  79. {
  80. return $this->_variableName;
  81. }
  82. }