lithium\analysis\Docblock::tags()
Parses @<tagname>
docblock tags and their descriptions from a docblock.
See the $tags
property for the list of supported tags.
Parameters
-
string
$string
The string to be parsed for tags
Returns
arrayReturns an array where each docblock tag is a key name, and the corresponding values are either strings (if one of each tag), or arrays (if multiple of the same tag).
Source
public static function tags($string) {
$regex = '/\n@(?P<type>' . join('|', static::$tags) . ")/msi";
$string = trim($string);
$result = preg_split($regex, "\n$string", -1, PREG_SPLIT_DELIM_CAPTURE);
$tags = array();
for ($i = 1; $i < count($result) - 1; $i += 2) {
$type = trim(strtolower($result[$i]));
$text = trim($result[$i + 1]);
if (isset($tags[$type])) {
$tags[$type] = is_array($tags[$type]) ? $tags[$type] : (array) $tags[$type];
$tags[$type][] = $text;
} else {
$tags[$type] = $text;
}
}
if (isset($tags['param'])) {
$tags['params'] = static::_params((array) $tags['param']);
unset($tags['param']);
}
return $tags;
}