Skip to content
Open
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: 4 additions & 0 deletions src/DocBlock/DescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ private function lex(string $contents): array
# Notice that this also matches "{}", as a way to later introduce it as an escape sequence.
\{(?1)?\}
|
# Match a balanced pair of braces that is not an inline tag, e.g. "{braces}" used as part
# of the description of a surrounding inline tag.
\{[^{}]*\}
|
# Make sure we match hanging "{".
\{
)
Expand Down
27 changes: 27 additions & 0 deletions tests/unit/DocBlock/DescriptionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,33 @@ public function testDescriptionCanParseAStringStartingWithInlineTag(): 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 testDescriptionCanParseStringWithInlineTagContainingBalancedBraces(): void
{
$contents = 'This description has a {@link http://phpdoc.org/ This contains {braces}} in it.';
$context = new Context('');
$tagFactory = m::mock(TagFactory::class);
$tagFactory->shouldReceive('create')
->once()
->with('@link http://phpdoc.org/ This contains {braces}', $context)
->andReturn(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 in it.', $description->getBodyTemplate());
}

/**
* @uses \phpDocumentor\Reflection\DocBlock\Description
* @uses \phpDocumentor\Reflection\DocBlock\Tags\Link
Expand Down