Quellcode durchsuchen

ZF-8373
- Fixed Zend_Reflection_Docblock_Tag_Param & Zend_Reflection_Docblock_Tag_Return to allow for array of types


git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24404 44c647ce-9c0f-0410-b52a-842ac1e357ba

ralph vor 14 Jahren
Ursprung
Commit
496a71879b

+ 1 - 1
library/Zend/Reflection/Docblock/Tag/Param.php

@@ -49,7 +49,7 @@ class Zend_Reflection_Docblock_Tag_Param extends Zend_Reflection_Docblock_Tag
     {
         $matches = array();
 
-        if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)\s+([^\s]+)(?:\s+(\$\S+))?(?:\s+(.*))?#s', $tagDocblockLine, $matches)) {
             require_once 'Zend/Reflection/Exception.php';
             throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
         }

+ 2 - 2
library/Zend/Reflection/Docblock/Tag/Return.php

@@ -39,11 +39,11 @@ class Zend_Reflection_Docblock_Tag_Return extends Zend_Reflection_Docblock_Tag
      * Constructor
      *
      * @param  string $tagDocblockLine
-     * @return void
+     * @return \Zend_Reflection_Docblock_Tag_Return
      */
     public function __construct($tagDocblockLine)
     {
-        if (!preg_match('#^@(\w+)\s+([\w|\\\]+)(?:\s+(.*))?#', $tagDocblockLine, $matches)) {
+        if (!preg_match('#^@(\w+)\s+([^\s]+)(?:\s+(.*))?#', $tagDocblockLine, $matches)) {
             require_once 'Zend/Reflection/Exception.php';
             throw new Zend_Reflection_Exception('Provided docblock line is does not contain a valid tag');
         }

+ 13 - 0
tests/Zend/Reflection/Docblock/Tag/ParamTest.php

@@ -21,6 +21,7 @@
  */
 
 require_once 'Zend/Reflection/File.php';
+require_once 'Zend/Reflection/Docblock/Tag/Param.php';
 
 /**
  * @category   Zend
@@ -87,5 +88,17 @@ class Zend_Reflection_Docblock_Tag_ParamTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('$var', $paramTag->getVariableName());
         $this->assertEquals('desc', $paramTag->getDescription());
     }
+
+    /**
+     * @group ZF-8373
+     */
+    public function testArrayNotationInParam()
+    {
+        $targetLine = '@param string[] $foo An array of strings';
+        $param = new Zend_Reflection_Docblock_Tag_Param($targetLine);
+        $this->assertEquals('string[]', $param->getType());
+        $this->assertEquals('$foo', $param->getVariableName());
+        $this->assertEquals('An array of strings', $param->getDescription());
+    }
 }
 

+ 12 - 0
tests/Zend/Reflection/Docblock/Tag/ReturnTest.php

@@ -76,4 +76,16 @@ class Zend_Reflection_Docblock_Tag_ReturnTest extends PHPUnit_Framework_TestCase
 
         $this->assertEquals('Zend\Reflection\Docblock', $paramTag->getType());
     }
+
+    /**
+     * @group ZF-8373
+     */
+    public function testArrayNotationInParam()
+    {
+        $targetLine = '@param string[] $foo An array of strings';
+        $param = new Zend_Reflection_Docblock_Tag_Param($targetLine);
+        $this->assertEquals('string[]', $param->getType());
+        $this->assertEquals('$foo', $param->getVariableName());
+        $this->assertEquals('An array of strings', $param->getDescription());
+    }
 }