Moved parseDocComment from PluginManager to Utils

This commit is contained in:
Dylan K. Taylor
2018-05-13 11:24:04 +01:00
parent edaef588ab
commit 34b8557094
2 changed files with 16 additions and 13 deletions

View File

@ -622,4 +622,17 @@ class Utils{
public static function cleanPath($path){
return str_replace(["\\", ".php", "phar://", str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH)], ["/", "", "", "", ""], $path);
}
/**
* Extracts one-line tags from the doc-comment
*
* @param string $docComment
*
* @return string[] an array of tagName => tag value. If the tag has no value, an empty string is used as the value.
*/
public static function parseDocComment(string $docComment) : array{
preg_match_all('/^[\t ]*\* @([a-zA-Z]+)(?:[\t ]+(.+))?[\t ]*$/m', $docComment, $matches);
return array_combine($matches[1], array_map("trim", $matches[2]));
}
}