mirror of
https://github.com/barryvdh/ReflectionDocBlock.git
synced 2026-08-18 01:57:13 +00:00
Bugfix: resolve issue with multiline descriptions
The phpstan parser is not consuming the full description when parsing docblocks with a more complex description. For them it's mostlikely not an issue as phpstan doesn't use the descriptions. But it will also parse the descriptions into unexpected tags. This could be an advantage but is not according to the phpdoc spec. Our own tokenizer is already tokenizing the docblocks into the correct parts. So all we needed to do is assume all remaining tokens in the phpstan ast belong to the description. From there our own code is able to handle this as before in v5.3. fixes #365
This commit is contained in:
@@ -26,6 +26,8 @@ use PHPStan\PhpDocParser\Parser\TokenIterator;
|
||||
use PHPStan\PhpDocParser\Parser\TypeParser;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
use function property_exists;
|
||||
|
||||
abstract class TagFactoryTestCase extends TestCase
|
||||
{
|
||||
public function parseTag(string $tag): PhpDocTagNode
|
||||
@@ -34,7 +36,12 @@ abstract class TagFactoryTestCase extends TestCase
|
||||
$tokens = $lexer->tokenize($tag);
|
||||
$constParser = new ConstExprParser();
|
||||
|
||||
return (new PhpDocParser(new TypeParser($constParser), $constParser))->parseTag(new TokenIterator($tokens));
|
||||
$tagNode = (new PhpDocParser(new TypeParser($constParser), $constParser))->parseTag(new TokenIterator($tokens));
|
||||
if (property_exists($tagNode->value, 'description') === true) {
|
||||
$tagNode->value->setAttribute('description', $tagNode->value->description);
|
||||
}
|
||||
|
||||
return $tagNode;
|
||||
}
|
||||
|
||||
public function giveTypeResolver(): TypeResolver
|
||||
|
||||
Reference in New Issue
Block a user