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

Issue Type: Patch Created: 2011-06-03T13:37:35.000+0000 Last Updated: 2013-01-17T20:06:29.000+0000 Status: Open Fix version(s): Reporter: Arkadiusz Jablonski (arek) Assignee: Ralph Schindler (ralph) Tags: - Zend_Reflection

  • zend_reflection_class

Related issues: Attachments:


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

<pre class="highlight">
$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:

<pre class="highlight">
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));


Posted by Jacek Kobus ( on 2013-01-17T20:06:28.000+0000

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

Have you found an issue?

See the Overview section for more details.


© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.