* @since 2.0 */ class HelpParser { /** * Returns the first line of docblock. * * @param \Reflector $reflector * @return string */ public static function getSummary(\Reflector $reflector) { $docLines = preg_split('~\R~', $reflector->getDocComment()); if (isset($docLines[1])) { return trim($docLines[1], ' *'); } return ''; } /** * Returns full description from the docblock. * * @param \Reflector $reflector * @return string */ public static function getDetail(\Reflector $reflector) { $comment = strtr(trim(preg_replace('/^\s*\**( |\t)?/m', '', trim($reflector->getDocComment(), '/'))), "\r", ''); if (preg_match('/^\s*@\w+/m', $comment, $matches, PREG_OFFSET_CAPTURE)) { $comment = trim(substr($comment, 0, $matches[0][1])); } if ($comment !== '') { return rtrim(Console::renderColoredString(Console::markdownToAnsi($comment))); } return ''; } }