diff --git a/src/DocBlock/DescriptionFactory.php b/src/DocBlock/DescriptionFactory.php index c27d2a01..fdcde26b 100644 --- a/src/DocBlock/DescriptionFactory.php +++ b/src/DocBlock/DescriptionFactory.php @@ -117,7 +117,7 @@ private function lex(string $contents) : array \{ ) # Match content after the nested inline tag. - [^{}]* + [^{]* )* # If there are more inline tags, match them as well. We use "*" since there may not be any # nested inline tags. ) diff --git a/tests/unit/DocBlock/DescriptionFactoryTest.php b/tests/unit/DocBlock/DescriptionFactoryTest.php index 04280fdb..bcd0b033 100644 --- a/tests/unit/DocBlock/DescriptionFactoryTest.php +++ b/tests/unit/DocBlock/DescriptionFactoryTest.php @@ -220,6 +220,36 @@ public function testDescriptionWithBrokenInlineTags() : void $this->assertSame($contents, $description->render()); } + /** + * @uses \phpDocumentor\Reflection\DocBlock\Description + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Link + * @uses \phpDocumentor\Reflection\DocBlock\Tags\BaseTag + * @uses \phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter + * @uses \phpDocumentor\Reflection\Types\Context + * + * @covers ::__construct + * @covers ::create + */ + public function testDescriptionCanParseStringWithInlineTagAndBraces() : void + { + $contents = 'This description has a {@link http://phpdoc.org/ This contains {braces} }'; + $context = new Context(''); + $tagFactory = m::mock(TagFactory::class); + $tagFactory->shouldReceive('create') + ->twice() + ->andReturnValues( + [ + new LinkTag('http://phpdoc.org/', new Description('This contains {braces}')), + ] + ); + + $factory = new DescriptionFactory($tagFactory); + $description = $factory->create($contents, $context); + + $this->assertSame($contents, $description->render()); + $this->assertSame('This description has a %1$s', $description->getBodyTemplate()); + } + /** * Provides a series of example strings that the parser should correctly interpret and return. *