Skip to content

Commit

Permalink
Tests for comment-like descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ondrejmirtes committed Oct 9, 2023
1 parent bcad8d9 commit 0bb2fe4
Showing 1 changed file with 93 additions and 0 deletions.
93 changes: 93 additions & 0 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ protected function setUp(): void
* @dataProvider provideParamOutTagsData
* @dataProvider provideDoctrineData
* @dataProvider provideDoctrineWithoutDoctrineCheckData
* @dataProvider provideCommentLikeDescriptions
*/
public function testParse(
string $label,
Expand Down Expand Up @@ -5561,6 +5562,98 @@ public function provideSelfOutTagsData(): Iterator
];
}

public function provideCommentLikeDescriptions(): Iterator
{
yield [
'Comment after @param',
'/** @param int $a // this is a description */',
new PhpDocNode([
new PhpDocTagNode('@param', new ParamTagValueNode(
new IdentifierTypeNode('int'),
false,
'$a',
'// this is a description'
)),
]),
];

yield [
'Comment on a separate line',
'/**' . PHP_EOL .
' * @param int $a' . PHP_EOL .
' * // this is a comment' . PHP_EOL .
' */',
new PhpDocNode([
new PhpDocTagNode('@param', new ParamTagValueNode(
new IdentifierTypeNode('int'),
false,
'$a',
''
)),
new PhpDocTextNode('// this is a comment'),
]),
];
yield [
'Comment on a separate line 2',
'/**' . PHP_EOL .
' * @param int $a' . PHP_EOL .
' *' . PHP_EOL .
' * // this is a comment' . PHP_EOL .
' */',
new PhpDocNode([
new PhpDocTagNode('@param', new ParamTagValueNode(
new IdentifierTypeNode('int'),
false,
'$a',
''
)),
new PhpDocTextNode(''),
new PhpDocTextNode('// this is a comment'),
]),
];
yield [
'Comment after Doctrine tag 1',
'/** @ORM\Doctrine // this is a description */',
new PhpDocNode([
new PhpDocTagNode('@ORM\Doctrine', new GenericTagValueNode('// this is a description')),
]),
];
yield [
'Comment after Doctrine tag 2',
'/** @\ORM\Doctrine // this is a description */',
new PhpDocNode([
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
new DoctrineAnnotation('@\ORM\Doctrine', []),
'// this is a description'
)),
]),
];
yield [
'Comment after Doctrine tag 3',
'/** @\ORM\Doctrine() // this is a description */',
new PhpDocNode([
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
new DoctrineAnnotation('@\ORM\Doctrine', []),
'// this is a description'
)),
]),
];
yield [
'Comment after Doctrine tag 4',
'/** @\ORM\Doctrine() @\ORM\Entity() // this is a description */',
new PhpDocNode([
new PhpDocTagNode('@\ORM\Doctrine', new DoctrineTagValueNode(
new DoctrineAnnotation('@\ORM\Doctrine', []),
''
)),
new PhpDocTagNode('@\ORM\Entity', new DoctrineTagValueNode(
new DoctrineAnnotation('@\ORM\Entity', []),
'// this is a description'
)),
]),
];
}

public function provideParamOutTagsData(): Iterator
{
yield [
Expand Down

0 comments on commit 0bb2fe4

Please sign in to comment.