Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
fix issue where getMethodContents was calling declaring classes filen…
Browse files Browse the repository at this point in the history
…ame causing issues lookingup methods of traits
  • Loading branch information
steverhoades committed Sep 14, 2014
1 parent 27d5bb7 commit d25bffa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion library/Zend/Code/Reflection/MethodReflection.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function getBody()
*/
protected function extractMethodContents($bodyOnly=false)
{
$fileName = $this->getDeclaringClass()->getFileName();
$fileName = $this->getFileName();

if ((class_exists($this->class) && false === $fileName) || ! file_exists($fileName)) {
return '';
Expand Down
10 changes: 5 additions & 5 deletions tests/ZendTest/Code/Reflection/MethodReflectionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -359,11 +359,11 @@ public function testCodeGetBodyReturnsEmptyWithCommentedFunction()
*/
public function testCanParseClassBodyWhenUsingTrait()
{
include __DIR__ .'/TestAsset/TestTraitClass1.php';
require_once __DIR__ .'/TestAsset/TestTraitClass1.php';
require_once __DIR__. '/TestAsset/TestTraitClass2.php';
$method = new \Zend\Code\Reflection\ClassReflection('\FooClass');
$traits = current($method->getTraits());

$this->assertEquals(trim($traits->getMethod('getDummy')->getBody()), 'return $this->dummy;');
// $method = new \Zend\Code\Reflection\ClassReflection('\FooClass');
// $traits = current($method->getTraits());
$method = new \Zend\Code\Reflection\MethodReflection('FooClass', 'getDummy');
$this->assertEquals(trim($method->getBody()), 'return $this->dummy;');
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
//issue #6620
include_once 'TestTraitClass2.php';
require_once 'TestTraitClass2.php';
class FooClass
{
use TestTrait;
Expand Down

0 comments on commit d25bffa

Please # to comment.