From a5e938b30cd9efabc77287d89fdb3db147a658c4 Mon Sep 17 00:00:00 2001 From: Ondrej Mirtes Date: Sun, 15 Sep 2024 21:01:23 +0200 Subject: [PATCH] Test for special multiline PHPDoc --- tests/PHPStan/Parser/PhpDocParserTest.php | 79 +++++++++++++++++++++++ 1 file changed, 79 insertions(+) diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index a4da273..f765015 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -3881,6 +3881,46 @@ public function provideMultiLinePhpDocData(): iterable new PhpDocTextNode('test'), ]), ]; + + yield [ + 'Real-world test case multiline PHPDoc', + '/**' . PHP_EOL . + ' *' . PHP_EOL . + ' * MultiLine' . PHP_EOL . + ' * description' . PHP_EOL . + ' * @param bool $a' . PHP_EOL . + ' *' . PHP_EOL . + ' * @return void' . PHP_EOL . + ' *' . PHP_EOL . + ' * @throws \Exception' . PHP_EOL . + ' *' . PHP_EOL . + ' */', + new PhpDocNode([ + new PhpDocTextNode(''), + new PhpDocTextNode( + 'MultiLine' . PHP_EOL . + 'description' + ), + new PhpDocTagNode('@param', new ParamTagValueNode( + new IdentifierTypeNode('bool'), + false, + '$a', + '', + false + )), + new PhpDocTextNode(''), + new PhpDocTagNode('@return', new ReturnTagValueNode( + new IdentifierTypeNode('void'), + '' + )), + new PhpDocTextNode(''), + new PhpDocTagNode('@throws', new ThrowsTagValueNode( + new IdentifierTypeNode('\Exception'), + '' + )), + new PhpDocTextNode(''), + ]), + ]; } public function provideTemplateTagsData(): Iterator @@ -7582,6 +7622,45 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable ), ]), ]; + + yield [ + '/**' . PHP_EOL . + ' *' . PHP_EOL . + ' * MultiLine' . PHP_EOL . + ' * description' . PHP_EOL . + ' * @param bool $a' . PHP_EOL . + ' *' . PHP_EOL . + ' * @return void' . PHP_EOL . + ' *' . PHP_EOL . + ' * @throws \Exception' . PHP_EOL . + ' *' . PHP_EOL . + ' */', + new PhpDocNode([ + new PhpDocTextNode( + PHP_EOL . + 'MultiLine' . PHP_EOL . + 'description' + ), + new PhpDocTagNode('@param', new ParamTagValueNode( + new IdentifierTypeNode('bool'), + false, + '$a', + '', + false + )), + new PhpDocTextNode(''), + new PhpDocTagNode('@return', new ReturnTagValueNode( + new IdentifierTypeNode('void'), + '' + )), + new PhpDocTextNode(''), + new PhpDocTagNode('@throws', new ThrowsTagValueNode( + new IdentifierTypeNode('\Exception'), + '' + )), + new PhpDocTextNode(''), + ]), + ]; } /**