Просмотр исходного кода

ZF-7213
- Fixed formatting issues with Docblock Param Tag and Other tag generators

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

ralph 16 лет назад
Родитель
Сommit
b7a115c1de

+ 3 - 3
library/Zend/CodeGenerator/Php/Docblock.php

@@ -192,7 +192,7 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
         }
 
         foreach ($this->getTags() as $tag) {
-            $output .= $tag->generate();
+            $output .= $tag->generate() . self::LINE_FEED;
         }
         
         return $this->_docCommentize(trim($output));
@@ -208,8 +208,8 @@ class Zend_CodeGenerator_Php_Docblock extends Zend_CodeGenerator_Php_Abstract
     {
         $indent = $this->getIndentation();
         $output = $indent . '/**' . self::LINE_FEED;
-        $content = wordwrap($content, 80, "\n");
-        $lines = explode("\n", $content);
+        $content = wordwrap($content, 80, self::LINE_FEED);
+        $lines = explode(self::LINE_FEED, $content);
         foreach ($lines as $line) {
             $output .= $indent . ' * ' . $line . self::LINE_FEED;
         }

+ 1 - 1
library/Zend/CodeGenerator/Php/Docblock/Tag.php

@@ -178,7 +178,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag extends Zend_CodeGenerator_Php_Abstrac
      */
     public function generate()
     {
-        return '@' . $this->_name . ' ' . $this->_description . self::LINE_FEED;
+        return '@' . $this->_name . ' ' . $this->_description;
     }
     
 }

+ 4 - 1
library/Zend/CodeGenerator/Php/Docblock/Tag/Param.php

@@ -118,7 +118,10 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Param extends Zend_CodeGenerator_Php_D
      */
     public function generate()
     {
-        $output = '@param ' . $this->_datatype . ' ' . $this->_paramName . ' ' . $this->_description . self::LINE_FEED;
+        $output = '@param ' 
+            . (($this->_datatype  != null) ? $this->_datatype : 'unknown')
+            . (($this->_paramName != null) ? ' $' . $this->_paramName : '') 
+            . (($this->_description != null) ? ' ' . $this->_description : '');
         return $output;
     }
     

+ 1 - 1
library/Zend/CodeGenerator/Php/Docblock/Tag/Return.php

@@ -91,7 +91,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_Return extends Zend_CodeGenerator_Php_
      */
     public function generate()
     {
-        $output = '@return ' . $this->_datatype . ' ' . $this->_description . self::LINE_FEED;
+        $output = '@return ' . $this->_datatype . ' ' . $this->_description;
         return $output;
     }
     

+ 9 - 1
tests/Zend/CodeGenerator/Php/Docblock/Tag/ParamTest.php

@@ -43,7 +43,7 @@ class Zend_CodeGenerator_Php_Docblock_Tag_ParamTest extends PHPUnit_Framework_Te
 {
     
     /**
-     * @var Zend_CodeGenerator_Php_Docblock_Tag
+     * @var Zend_CodeGenerator_Php_Docblock_Tag_Param
      */
     protected $_tag = null;
     
@@ -69,4 +69,12 @@ class Zend_CodeGenerator_Php_Docblock_Tag_ParamTest extends PHPUnit_Framework_Te
         $this->assertEquals('Foo', $this->_tag->getParamName());
     }
     
+    public function testParamProducesCorrectDocBlockLine()
+    {
+        $this->_tag->setParamName('foo');
+        $this->_tag->setDatatype('string');
+        $this->_tag->setDescription('bar bar bar');
+        $this->assertEquals('@param string $foo bar bar bar', $this->_tag->generate());
+    }
+    
 }

+ 1 - 1
tests/Zend/CodeGenerator/Php/DocblockTest.php

@@ -78,7 +78,7 @@ class Zend_CodeGenerator_Php_DocblockTest extends PHPUnit_Framework_TestCase
         $target = <<<EOS
 /**
  * @blah 
- * @param string  
+ * @param string
  * @return int
  */