Skip to content

Commit 0bb2fe4

Browse files
committed
Tests for comment-like descriptions
1 parent bcad8d9 commit 0bb2fe4

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed

tests/PHPStan/Parser/PhpDocParserTest.php

+93
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ protected function setUp(): void
117117
* @dataProvider provideParamOutTagsData
118118
* @dataProvider provideDoctrineData
119119
* @dataProvider provideDoctrineWithoutDoctrineCheckData
120+
* @dataProvider provideCommentLikeDescriptions
120121
*/
121122
public function testParse(
122123
string $label,
@@ -5561,6 +5562,98 @@ public function provideSelfOutTagsData(): Iterator
55615562
];
55625563
}
55635564

5565+
public function provideCommentLikeDescriptions(): Iterator
5566+
{
5567+
yield [
5568+
'Comment after @param',
5569+
'/** @param int $a // this is a description */',
5570+
new PhpDocNode([
5571+
new PhpDocTagNode('@param', new ParamTagValueNode(
5572+
new IdentifierTypeNode('int'),
5573+
false,
5574+
'$a',
5575+
'// this is a description'
5576+
)),
5577+
]),
5578+
];
5579+
5580+
yield [
5581+
'Comment on a separate line',
5582+
'/**' . PHP_EOL .
5583+
' * @param int $a' . PHP_EOL .
5584+
' * // this is a comment' . PHP_EOL .
5585+
' */',
5586+
new PhpDocNode([
5587+
new PhpDocTagNode('@param', new ParamTagValueNode(
5588+
new IdentifierTypeNode('int'),
5589+
false,
5590+
'$a',
5591+
''
5592+
)),
5593+
new PhpDocTextNode('// this is a comment'),
5594+
]),
5595+
];
5596+
yield [
5597+
'Comment on a separate line 2',
5598+
'/**' . PHP_EOL .
5599+
' * @param int $a' . PHP_EOL .
5600+
' *' . PHP_EOL .
5601+
' * // this is a comment' . PHP_EOL .
5602+
' */',
5603+
new PhpDocNode([
5604+
new PhpDocTagNode('@param', new ParamTagValueNode(
5605+
new IdentifierTypeNode('int'),
5606+
false,
5607+
'$a',
5608+
''
5609+
)),
5610+
new PhpDocTextNode(''),
5611+
new PhpDocTextNode('// this is a comment'),
5612+
]),
5613+
];
5614+
yield [
5615+
'Comment after Doctrine tag 1',
5616+
'/** @ORM\Doctrine // this is a description */',
5617+
new PhpDocNode([
5618+
new PhpDocTagNode('@ORM\Doctrine', new GenericTagValueNode('// this is a description')),
5619+
]),
5620+
];
5621+
yield [
5622+
'Comment after Doctrine tag 2',
5623+
'/** @\ORM\Doctrine // this is a description */',
5624+
new PhpDocNode([
5625+
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
5626+
new DoctrineAnnotation('@\ORM\Doctrine', []),
5627+
'// this is a description'
5628+
)),
5629+
]),
5630+
];
5631+
yield [
5632+
'Comment after Doctrine tag 3',
5633+
'/** @\ORM\Doctrine() // this is a description */',
5634+
new PhpDocNode([
5635+
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
5636+
new DoctrineAnnotation('@\ORM\Doctrine', []),
5637+
'// this is a description'
5638+
)),
5639+
]),
5640+
];
5641+
yield [
5642+
'Comment after Doctrine tag 4',
5643+
'/** @\ORM\Doctrine() @\ORM\Entity() // this is a description */',
5644+
new PhpDocNode([
5645+
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
5646+
new DoctrineAnnotation('@\ORM\Doctrine', []),
5647+
''
5648+
)),
5649+
new PhpDocTagNode('@\ORM\Entity', new DoctrineTagValueNode(
5650+
new DoctrineAnnotation('@\ORM\Entity', []),
5651+
'// this is a description'
5652+
)),
5653+
]),
5654+
];
5655+
}
5656+
55645657
public function provideParamOutTagsData(): Iterator
55655658
{
55665659
yield [

0 commit comments

Comments
 (0)