Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/grammars/lexemes.pp3
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@
* so that the "@baz" of "@author Foo <foo@baz.com>" belongs to the description
* it is written in.
*/
%token T_PHPDOC_TAG_WS (?<=[\x09\x20])@(?:[a-z][a-z0-9-\\]+:)?[a-z][a-z0-9-\\]*+
%token T_PHPDOC_TAG @(?:[a-z][a-z0-9-\\]+:)?[a-z][a-z0-9-\\]*+
%token T_PHPDOC_TAG_WS (?<=[\x09\x20])@(?:[a-z][a-z0-9-\\]+:)?[a-z][a-z0-9_\\-]*+
%token T_PHPDOC_TAG @(?:[a-z][a-z0-9-\\]+:)?[a-z][a-z0-9_\\-]*+
%token T_DOCTRINE_TAG_WS (?<=[\x09\x20])@[a-z_\\][a-z0-9_:\\]*[a-z_][a-z0-9_]*
%token T_DOCTRINE_TAG @[a-z_\\][a-z0-9_:\\]*[a-z_][a-z0-9_]*
%token T_PHPDOC_EOL \r?+\n[\x09\x20]*+(?:\*(?!/)\x20?+)?
Expand Down
2 changes: 1 addition & 1 deletion src/Lexer/Lexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ private function generateRegexp(): string

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

Expand Down
24 changes: 24 additions & 0 deletions tests/PHPStan/Parser/PhpDocParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6338,6 +6338,30 @@ public function provideTagsWithNumbers(): Iterator

public function provideTagsWithBackslash(): Iterator
{
yield [
'OK tag with underscore in it',
'/** @Foo_Bar User */',
new PhpDocNode([
new PhpDocTagNode(
'@Foo_Bar',
new GenericTagValueNode('User'),
),
]),
];

yield [
'OK tag with underscore in it and parenthesis',
'/** @Foo\Bar_Baz(name="column_id") */',
new PhpDocNode([
new PhpDocTagNode(
'@Foo\Bar_Baz',
new DoctrineTagValueNode(new DoctrineAnnotation('@Foo\Bar_Baz', [
new DoctrineArgument(new IdentifierTypeNode('name'), new DoctrineConstExprStringNode('column_id')),
]), ''),
),
]),
];

yield [
'OK without description and tag with backslashes in it',
'/** @ORM\Mapping\Entity User */',
Expand Down
Loading