diff --git a/examples/interpreting-a-simple-docblock.php b/examples/01-interpreting-a-simple-docblock.php similarity index 100% rename from examples/interpreting-a-simple-docblock.php rename to examples/01-interpreting-a-simple-docblock.php diff --git a/examples/02-interpreting-tags.php b/examples/02-interpreting-tags.php new file mode 100644 index 0000000..2399588 --- /dev/null +++ b/examples/02-interpreting-tags.php @@ -0,0 +1,24 @@ +create($docComment); + +// You can check if a DocBlock has one or more see tags +$hasSeeTag = $docblock->hasTag('see'); + +// Or we can get a complete list of all tags +$tags = $docblock->getTags(); + +// But we can also grab all tags of a specific type, such as `see` +$seeTags = $docblock->getTagsByName('see'); diff --git a/tests/integration/InterpretingDocBlocksTest.php b/tests/integration/InterpretingDocBlocksTest.php index ec90fae..dda3663 100644 --- a/tests/integration/InterpretingDocBlocksTest.php +++ b/tests/integration/InterpretingDocBlocksTest.php @@ -13,6 +13,9 @@ namespace phpDocumentor\Reflection; use phpDocumentor\Reflection\DocBlock\Description; +use phpDocumentor\Reflection\DocBlock\StandardTagFactory; +use phpDocumentor\Reflection\DocBlock\Tag; +use phpDocumentor\Reflection\DocBlock\Tags\See; /** * @coversNothing @@ -29,7 +32,7 @@ class InterpretingDocBlocksTest extends \PHPUnit_Framework_TestCase * @var string $summary * @var Description $description */ - include(__DIR__ . '/../../examples/interpreting-a-simple-docblock.php'); + include(__DIR__ . '/../../examples/01-interpreting-a-simple-docblock.php'); $descriptionText = <<assertSame($descriptionText, $description->render()); $this->assertEmpty($docblock->getTags()); } + + public function testInterpretingTags() + { + /** + * @var DocBlock $docblock + * @var boolean $hasSeeTag + * @var Tag[] $tags + * @var See[] $seeTags + */ + include(__DIR__ . '/../../examples/02-interpreting-tags.php'); + + $this->assertTrue($hasSeeTag); + $this->assertCount(1, $tags); + $this->assertCount(1, $seeTags); + + $this->assertInstanceOf(See::class, $tags[0]); + $this->assertInstanceOf(See::class, $seeTags[0]); + + $seeTag = $seeTags[0]; + $this->assertSame('\\' . StandardTagFactory::class, (string)$seeTag->getReference()); + $this->assertSame('', (string)$seeTag->getDescription()); + } }