File indexing completed on 2024-06-23 05:55:36

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_Reflection
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  * @version    $Id$
0020  */
0021 
0022 /** Zend_Reflection_Docblock_Tag */
0023 // require_once 'Zend/Reflection/Docblock/Tag.php';
0024 
0025 /**
0026  * @category   Zend
0027  * @package    Zend_Reflection
0028  * @copyright  Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
0029  * @license    http://framework.zend.com/license/new-bsd     New BSD License
0030  */
0031 class Zend_Reflection_Docblock_Tag_Param extends Zend_Reflection_Docblock_Tag
0032 {
0033     /**
0034      * @var string
0035      */
0036     protected $_type = null;
0037 
0038     /**
0039      * @var string
0040      */
0041     protected $_variableName = null;
0042 
0043     /**
0044      * Constructor
0045      *
0046      * @param string $tagDocblockLine
0047      */
0048     public function __construct($tagDocblockLine)
0049     {
0050         $matches = array();
0051 
0052         if (!preg_match('#^@(\w+)\s+([^\s]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
0053             // require_once 'Zend/Reflection/Exception.php';
0054             throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
0055         }
0056 
0057         if ($matches[1] != 'param') {
0058             // require_once 'Zend/Reflection/Exception.php';
0059             throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid @param tag');
0060         }
0061 
0062         $this->_name = 'param';
0063         $this->_type = $matches[2];
0064 
0065         if (isset($matches[3])) {
0066             $this->_variableName = $matches[3];
0067         }
0068 
0069         if (isset($matches[4])) {
0070             $this->_description = preg_replace('#\s+#', ' ', $matches[4]);
0071         }
0072     }
0073 
0074     /**
0075      * Get parameter variable type
0076      *
0077      * @return string
0078      */
0079     public function getType()
0080     {
0081         return $this->_type;
0082     }
0083 
0084     /**
0085      * Get parameter name
0086      *
0087      * @return string
0088      */
0089     public function getVariableName()
0090     {
0091         return $this->_variableName;
0092     }
0093 }