File tree Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Expand file tree Collapse file tree 3 files changed +29
-2
lines changed Original file line number Diff line number Diff line change 77use PHPStan \PhpDocParser \Lexer \Lexer ;
88use function in_array ;
99use function str_replace ;
10+ use function strlen ;
1011use function strpos ;
12+ use function substr_compare ;
1113use function trim ;
1214
1315class TypeParser
@@ -380,10 +382,16 @@ public function isHtml(TokenIterator $tokens): bool
380382 return false ;
381383 }
382384
385+ $ endTag = '</ ' . $ htmlTagName . '> ' ;
386+ $ endTagSearchOffset = - strlen ($ endTag );
387+
383388 while (!$ tokens ->isCurrentTokenType (Lexer::TOKEN_END )) {
384389 if (
385- $ tokens ->tryConsumeTokenType (Lexer::TOKEN_OPEN_ANGLE_BRACKET )
386- && strpos ($ tokens ->currentTokenValue (), '/ ' . $ htmlTagName . '> ' ) !== false
390+ (
391+ $ tokens ->tryConsumeTokenType (Lexer::TOKEN_OPEN_ANGLE_BRACKET )
392+ && strpos ($ tokens ->currentTokenValue (), '/ ' . $ htmlTagName . '> ' ) !== false
393+ )
394+ || substr_compare ($ tokens ->currentTokenValue (), $ endTag , $ endTagSearchOffset ) === 0
387395 ) {
388396 return true ;
389397 }
Original file line number Diff line number Diff line change @@ -1301,6 +1301,20 @@ public function provideReturnTagsData(): Iterator
13011301 ]),
13021302 ];
13031303
1304+ yield [
1305+ 'OK with HTML description ' ,
1306+ '/** @return MongoCollection <p>Returns a collection object representing the new collection.</p> */ ' ,
1307+ new PhpDocNode ([
1308+ new PhpDocTagNode (
1309+ '@return ' ,
1310+ new ReturnTagValueNode (
1311+ new IdentifierTypeNode ('MongoCollection ' ),
1312+ '<p>Returns a collection object representing the new collection.</p> '
1313+ )
1314+ ),
1315+ ]),
1316+ ];
1317+
13041318 yield [
13051319 'invalid without type and description ' ,
13061320 '/** @return */ ' ,
Original file line number Diff line number Diff line change @@ -2166,6 +2166,11 @@ public function provideParseData(): array
21662166 false
21672167 )),
21682168 ],
2169+ [
2170+ 'MongoCollection <p>Returns a collection object representing the new collection.</p> ' ,
2171+ new IdentifierTypeNode ('MongoCollection ' ),
2172+ Lexer::TOKEN_OPEN_ANGLE_BRACKET ,
2173+ ],
21692174 ];
21702175 }
21712176
You can’t perform that action at this time.
0 commit comments