Skip to content

Commit

Permalink
Add specialized tags support
Browse files Browse the repository at this point in the history
Specialized tags are tags including a signle colon.
  • Loading branch information
jaapio authored and ondrejmirtes committed Nov 20, 2022
1 parent 066f9d0 commit aac4411
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Lexer/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function generateRegexp(): string

self::TOKEN_OPEN_PHPDOC => '/\\*\\*(?=\\s)\\x20?+',
self::TOKEN_CLOSE_PHPDOC => '\\*/',
self::TOKEN_PHPDOC_TAG => '@[a-z][a-z0-9-\\\\]*+',
self::TOKEN_PHPDOC_TAG => '@(?:[a-z][a-z0-9-\\\\]+:)?[a-z][a-z0-9-\\\\]*+',
self::TOKEN_PHPDOC_EOL => '\\r?+\\n[\\x09\\x20]*+(?:\\*(?!/)\\x20?+)?',

self::TOKEN_FLOAT => '(?:-?[0-9]++\\.[0-9]*+(?:e-?[0-9]++)?)|(?:-?[0-9]*+\\.[0-9]++(?:e-?[0-9]++)?)|(?:-?[0-9]++e-?[0-9]++)',
Expand Down
17 changes: 17 additions & 0 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ protected function setUp(): void

/**
* @dataProvider provideTagsWithNumbers
* @dataProvider provideSpecializedTags
* @dataProvider provideParamTagsData
* @dataProvider provideTypelessParamTagsData
* @dataProvider provideVarTagsData
Expand Down Expand Up @@ -4851,6 +4852,22 @@ public function provideParamOutTagsData(): Iterator
];
}

public function provideSpecializedTags(): Iterator
{
yield [
'Ok specialized tag',
'/** @special:param this is special */',
new PhpDocNode([
new PhpDocTagNode(
'@special:param',
new GenericTagValueNode(
'this is special'
)
),
]),
];
}

/**
* @dataProvider dataParseTagValue
* @param PhpDocNode $expectedPhpDocNode
Expand Down

0 comments on commit aac4411

Please sign in to comment.