Skip to content

Commit

Permalink
- Add getMethodSource() method.
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Jun 23, 2007
1 parent cac51ac commit 05bbd61
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions PHPUnit/Util/Class.php
Expand Up @@ -153,5 +153,18 @@ public static function getHierarchy($className)


return $classes; return $classes;
} }

public static function getMethodSource($className, $methodName)
{
$method = new ReflectionMethod($className, $methodName);
$file = file($method->getFileName());
$result = '';

for ($line = $method->getStartLine() - 1; $line <= $method->getEndLine() - 1; $line++) {
$result .= $file[$line];
}

return $result;
}
} }
?> ?>

0 comments on commit 05bbd61

Please sign in to comment.