Skip to content

Commit

Permalink
Use regex instead of str_replace.
Browse files Browse the repository at this point in the history
  • Loading branch information
SerkanYildiz committed Dec 12, 2018
1 parent ca79832 commit 6cbcc61
Showing 1 changed file with 2 additions and 8 deletions.
Expand Up @@ -293,14 +293,8 @@ public static function getClassDescription(string $class, string &$resolvedClass
$resolvedClass = $class;
try {
$r = new \ReflectionClass($class);
if($docComment = $r->getDocComment()){
$summary = str_replace(
array('/', '*', "\t", "\r\n", "\n", "\r", ' '),
'',
substr($docComment, 0, strpos($docComment, '@'))
);

return trim($summary);
if (('' !== $docComment = $r->getDocComment()) && false !== preg_match('~\s*/\*\*\s+\*\s*(?<!@)(\w.+)~', $docComment, $matches)) {
return isset($matches[1]) ? trim($matches[1]) : '';
}
} catch (\ReflectionException $e) {
}
Expand Down

0 comments on commit 6cbcc61

Please sign in to comment.