Skip to content

Commit

Permalink
Candidate fix for issue phpDocumentor#255 : loosen up inline tag spli…
Browse files Browse the repository at this point in the history
…tting regexp
  • Loading branch information
tipiak75 committed Oct 12, 2020
1 parent 069a785 commit 9ec8f7a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/DocBlock/DescriptionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
)
Expand Down
30 changes: 30 additions & 0 deletions tests/unit/DocBlock/DescriptionFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand Down

0 comments on commit 9ec8f7a

Please sign in to comment.