mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-20 18:06:40 +00:00
Utils: fixed parseDocComment() ignoring tags containing hyphens
This commit is contained in:
parent
5c7125f190
commit
b784a04e08
@ -506,7 +506,7 @@ final class Utils{
|
|||||||
if($rawDocComment === false){ //usually empty doc comment, but this is safer and statically analysable
|
if($rawDocComment === false){ //usually empty doc comment, but this is safer and statically analysable
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
|
preg_match_all('/(*ANYCRLF)^[\t ]*(?:\* )?@([a-zA-Z\-]+)(?:[\t ]+(.+?))?[\t ]*$/m', $rawDocComment, $matches);
|
||||||
|
|
||||||
return array_combine($matches[1], $matches[2]);
|
return array_combine($matches[1], $matches[2]);
|
||||||
}
|
}
|
||||||
|
@ -90,6 +90,12 @@ class UtilsTest extends TestCase{
|
|||||||
self::assertCount(0, $tags);
|
self::assertCount(0, $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testParseDocCommentWithTagsContainingHyphens() : void{
|
||||||
|
$tags = Utils::parseDocComment("/** @phpstan-return list<string> */");
|
||||||
|
self::assertArrayHasKey("phpstan-return", $tags);
|
||||||
|
self::assertEquals("list<string>", $tags["phpstan-return"]);
|
||||||
|
}
|
||||||
|
|
||||||
public function testNamespacedNiceClosureName() : void{
|
public function testNamespacedNiceClosureName() : void{
|
||||||
//be careful with this test. The closure has to be declared on the same line as the assertion.
|
//be careful with this test. The closure has to be declared on the same line as the assertion.
|
||||||
self::assertSame('closure@' . Filesystem::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function() : void{}));
|
self::assertSame('closure@' . Filesystem::cleanPath(__FILE__) . '#L' . __LINE__, Utils::getNiceClosureName(function() : void{}));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user