ZF-11433: Zend_Reflection_Class::getContents() doesn't return expected code


I tried to get a content of the class using something like that:

$r = new Zend_Reflection_Class( 'My_Class' ); // My_Class is loaded by Zend_Autoloader
echo $r->getContents();

Unfortunately I got the content end of class's cropped with number lines how many lines wass in the docblock (7 lines of docblock then 7 lines was removed from the file content). Also one line was trimmed from the begining of code when I passed true to this method ($includeDocblock).

When I changed lines 109 and 110 then it looks ok in both cases.

Below added suggested patch for this method:

Index: Class.php
--- Class.php   (revision 24104)
+++ Class.php   (working copy)
@@ -106,8 +106,8 @@
         $filename  = $this->getFileName();
         $filelines = file($filename);
-        $startnum  = $this->getStartLine($includeDocblock);
-        $endnum    = $this->getEndLine() - $this->getStartLine();
+        $startnum  = $this->getStartLine($includeDocblock)-1;
+        $endnum    = $this->getEndLine() - $startnum;
         return implode('', array_splice($filelines, $startnum, $endnum, true));


This file also corrupts content if "interface" is placed line below "class" declaration. This might be related.