diff --git a/tests/PHPStan/Parser/PhpDocParserTest.php b/tests/PHPStan/Parser/PhpDocParserTest.php index 8e98d639..d8ede9db 100644 --- a/tests/PHPStan/Parser/PhpDocParserTest.php +++ b/tests/PHPStan/Parser/PhpDocParserTest.php @@ -6988,6 +6988,23 @@ public function testNegatedAssertionToString(): void $this->assertSame('@phpstan-assert !Type $param', $assertNode->__toString()); } + /** + * @dataProvider provideLexerData + */ + public function testClosingBraceInlineTag( + string $input, + array $expectedTokens, + ): void { + $tokens = new TokenIterator($this->lexer->tokenize($input)); + $this->assertEquals($expectedTokens, array_map( + fn ($token) => [ + $token[Lexer::TYPE_OFFSET], + $token[Lexer::VALUE_OFFSET], + ], + $tokens->getTokens(), + )); + } + /** * @return array */ @@ -7664,6 +7681,32 @@ public function dataTextBetweenTagsBelongsToDescription(): iterable ]; } + public function provideLexerData(): Iterator + { + yield ['{@link https://example.com}', [ + [Lexer::TOKEN_OPEN_CURLY_BRACKET, '{'], + [Lexer::TOKEN_PHPDOC_TAG, '@link'], + [Lexer::TOKEN_HORIZONTAL_WS, ' '], + [Lexer::TOKEN_IDENTIFIER, 'https'], + [Lexer::TOKEN_COLON, ':'], + [Lexer::TOKEN_OTHER, '//example.com'], + [Lexer::TOKEN_CLOSE_CURLY_BRACKET, '}'], + [Lexer::TOKEN_END, ''], + ]]; + + yield ['{@link https://example.com }', [ + [Lexer::TOKEN_OPEN_CURLY_BRACKET, '{'], + [Lexer::TOKEN_PHPDOC_TAG, '@link'], + [Lexer::TOKEN_HORIZONTAL_WS, ' '], + [Lexer::TOKEN_IDENTIFIER, 'https'], + [Lexer::TOKEN_COLON, ':'], + [Lexer::TOKEN_OTHER, '//example.com'], + [Lexer::TOKEN_HORIZONTAL_WS, ' '], + [Lexer::TOKEN_CLOSE_CURLY_BRACKET, '}'], + [Lexer::TOKEN_END, ''], + ]]; + } + /** * @dataProvider dataTextBetweenTagsBelongsToDescription */