From b01b477a2a8923558954c0bc62d3595db5505254 Mon Sep 17 00:00:00 2001 From: "Dylan K. Taylor" Date: Tue, 10 Jul 2018 12:45:35 +0100 Subject: [PATCH] Properly fixed newline issues when parsing doc comments fixes #2110 properly fixed @notHandler and such not being detected when CRLF is used --- src/pocketmine/utils/Utils.php | 4 +-- tests/phpunit/utils/UtilsTest.php | 50 +++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 tests/phpunit/utils/UtilsTest.php diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 290f5bd30..3c648bc02 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -630,9 +630,9 @@ class Utils{ * @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); + preg_match_all('/(*ANYCRLF)^[\t ]*\* @([a-zA-Z]+)(?:[\t ]+(.+))?[\t ]*$/m', $docComment, $matches); - return array_combine($matches[1], array_map("trim", $matches[2])); + return array_combine($matches[1], $matches[2]); } /** diff --git a/tests/phpunit/utils/UtilsTest.php b/tests/phpunit/utils/UtilsTest.php new file mode 100644 index 000000000..ece8e81ca --- /dev/null +++ b/tests/phpunit/utils/UtilsTest.php @@ -0,0 +1,50 @@ +