From 8d24ce351fd04908c1a737db973e9699c84e85ff Mon Sep 17 00:00:00 2001 From: Jaapio Date: Sun, 5 Jul 2015 11:30:12 +0200 Subject: [PATCH 1/2] fix type mapping for return tag --- src/DocBlock/StandardTagFactory.php | 2 +- .../unit/DocBlock/StandardTagFactoryTest.php | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/src/DocBlock/StandardTagFactory.php b/src/DocBlock/StandardTagFactory.php index dc90bf4..eda7c53 100644 --- a/src/DocBlock/StandardTagFactory.php +++ b/src/DocBlock/StandardTagFactory.php @@ -54,7 +54,7 @@ final class StandardTagFactory implements TagFactory 'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead', 'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property', 'property-write' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite', - 'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return', + 'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return_', 'see' => '\phpDocumentor\Reflection\DocBlock\Tags\See', 'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since', 'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source', diff --git a/tests/unit/DocBlock/StandardTagFactoryTest.php b/tests/unit/DocBlock/StandardTagFactoryTest.php index f3d461d..21cbacf 100644 --- a/tests/unit/DocBlock/StandardTagFactoryTest.php +++ b/tests/unit/DocBlock/StandardTagFactoryTest.php @@ -17,9 +17,11 @@ use phpDocumentor\Reflection\DocBlock\Tags\Author; use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; use phpDocumentor\Reflection\DocBlock\Tags\Generic; +use phpDocumentor\Reflection\DocBlock\Tags\Return_; use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\FqsenResolver; +use phpDocumentor\Reflection\TypeResolver; use phpDocumentor\Reflection\Types\Context; /** @@ -322,4 +324,35 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase $tagFactory->registerTagHandler('my-tag', 'stdClass'); } + + /** + * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct + * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService + * @covers ::create + */ + public function testReturntagIsMappedCorrectly() + { + $context = new Context(''); + + $descriptionFactory = m::mock(DescriptionFactory::class); + $descriptionFactory + ->shouldReceive('create') + ->once() + ->with('', $context) + ->andReturn(new Description('')) + ; + + $typeResolver = new TypeResolver(); + + $tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class)); + $tagFactory->addService($descriptionFactory, DescriptionFactory::class); + $tagFactory->addService($typeResolver, TypeResolver::class); + + + /** @var Return_ $tag */ + $tag = $tagFactory->create('@return mixed', $context); + + $this->assertInstanceOf(Return_::class, $tag); + $this->assertSame('return', $tag->getName()); + } } From 6a6a4ca739409c0ae4c5f618fd2aed051d9c6979 Mon Sep 17 00:00:00 2001 From: Jaapio Date: Sun, 5 Jul 2015 11:37:49 +0200 Subject: [PATCH 2/2] add missing @uses --- tests/unit/DocBlock/StandardTagFactoryTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tests/unit/DocBlock/StandardTagFactoryTest.php b/tests/unit/DocBlock/StandardTagFactoryTest.php index 21cbacf..0247da0 100644 --- a/tests/unit/DocBlock/StandardTagFactoryTest.php +++ b/tests/unit/DocBlock/StandardTagFactoryTest.php @@ -326,9 +326,12 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase } /** + * @covers ::create * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct * @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService - * @covers ::create + * @uses phpDocumentor\Reflection\Docblock\Description + * @uses phpDocumentor\Reflection\Docblock\Tags\Return_ + * @uses phpDocumentor\Reflection\Docblock\Tags\BaseTag */ public function testReturntagIsMappedCorrectly() {