diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 4dfac7721..6ea2dc603 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -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(), diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 968a90a2d..342bf58cb 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -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])); + } }