lithium\analysis\Docblock::comment PHP Method

comment() public static method

Parses a doc block into its major components of description, text and tags.
public static comment ( string $comment ) : array
$comment string The doc block string to be parsed
return array An associative array of the parsed comment, whose keys are `description`, `text` and `tags`.
    public static function comment($comment)
    {
        $text = null;
        $tags = array();
        $description = null;
        $comment = trim(preg_replace('/^(\\s*\\/\\*\\*|\\s*\\*{1,2}\\/|\\s*\\* ?)/m', '', $comment));
        $comment = str_replace("\r\n", "\n", $comment);
        if ($items = preg_split('/\\n@/ms', $comment, 2)) {
            list($description, $tags) = $items + array('', '');
            $tags = $tags ? static::tags("@{$tags}") : array();
        }
        if (strpos($description, "\n\n")) {
            list($description, $text) = explode("\n\n", $description, 2);
        }
        $text = trim($text);
        $description = trim($description);
        return compact('description', 'text', 'tags');
    }

Usage Example

 public function testParamTag()
 {
     $comment = "/**\n * Lithium is cool\n * @param string \$str Some string\n */";
     $expected = array('description' => 'Lithium is cool', 'text' => '', 'tags' => array('params' => array('$str' => array('type' => 'string', 'text' => 'Some string'))));
     $result = Docblock::comment($comment);
     $this->assertEqual($expected, $result);
 }
All Usage Examples Of lithium\analysis\Docblock::comment