mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 08:44:01 +00:00
Moved parseDocComment from PluginManager to Utils
This commit is contained in:
parent
edaef588ab
commit
34b8557094
@ -36,6 +36,7 @@ use pocketmine\Server;
|
||||
use pocketmine\timings\Timings;
|
||||
use pocketmine\timings\TimingsHandler;
|
||||
use pocketmine\utils\MainLogger;
|
||||
use pocketmine\utils\Utils;
|
||||
|
||||
/**
|
||||
* Manages all the plugins, Permissions and Permissibles
|
||||
@ -716,17 +717,6 @@ class PluginManager{
|
||||
--$this->eventCallDepth;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers all the events in the given Listener class
|
||||
*
|
||||
@ -743,7 +733,7 @@ class PluginManager{
|
||||
$reflection = new \ReflectionClass(get_class($listener));
|
||||
foreach($reflection->getMethods(\ReflectionMethod::IS_PUBLIC) as $method){
|
||||
if(!$method->isStatic()){
|
||||
$tags = self::parseDocComment((string) $method->getDocComment());
|
||||
$tags = Utils::parseDocComment((string) $method->getDocComment());
|
||||
if(isset($tags["notHandler"])){
|
||||
continue;
|
||||
}
|
||||
@ -789,7 +779,7 @@ class PluginManager{
|
||||
throw new PluginException($event . " is not an Event");
|
||||
}
|
||||
|
||||
$tags = self::parseDocComment((string) (new \ReflectionClass($event))->getDocComment());
|
||||
$tags = Utils::parseDocComment((string) (new \ReflectionClass($event))->getDocComment());
|
||||
if(isset($tags["deprecated"]) and $this->server->getProperty("settings.deprecated-verbose", true)){
|
||||
$this->server->getLogger()->warning($this->server->getLanguage()->translateString("pocketmine.plugin.deprecatedEvent", [
|
||||
$plugin->getName(),
|
||||
|
@ -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]));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user