ZF-11386: Zend_CodeGenerator_Php_Docblock::_docCommentize() produces extra lines

Description

{{Zend_CodeGenerator_Php_Docblock::_docCommentize()}} produces an extra line within doc blocks. This affects all doc blocks within a generated file and compounds itself each time, for example, a new method is added to an existing class.

Expected output:


/**
 * Get imageName
 *
 * @return string $imageName
 */

Actual output (1st pass):


/**
 * Get imageName
 *
 * @return string $imageName
 *
 */

Actual output (2nd pass):


/**
 * Get imageName
 *
 * @return string $imageName
 *
 *
 */

Suggested patch:


### Eclipse Workspace Patch 1.0
#P framework
Index: libs/Zend/CodeGenerator/Php/Docblock.php
===================================================================
--- libs/Zend/CodeGenerator/Php/Docblock.php    (revision 24463)
+++ libs/Zend/CodeGenerator/Php/Docblock.php    (working copy)
@@ -209,13 +209,20 @@
         $indent = $this->getIndentation();
         $output = $indent . '/**' . self::LINE_FEED;
         $content = wordwrap($content, 80, self::LINE_FEED);
+        
         $lines = explode(self::LINE_FEED, $content);
+        $lastLine = count($lines);
+        $counter = 0;
         foreach ($lines as $line) {
-            $output .= $indent . ' *';
-            if ($line) {
-                $output .= " $line";
-            }
-            $output .= self::LINE_FEED;
+           if (($lastLine == ++$counter) && empty($line)) {
+               continue;
+           }
+           
+           $output .= $indent . ' *';
+           if ($line) {
+               $output .= " $line";
+           }
+           $output .= self::LINE_FEED;
         }
         $output .= $indent . ' */' . self::LINE_FEED;
         return $output;

Comments

Updated code patch after further testing.