fix type mapping for return tag

This commit is contained in:
Jaapio
2015-07-05 11:30:12 +02:00
parent ed4c6b77ab
commit 8d24ce351f
2 changed files with 34 additions and 1 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ final class StandardTagFactory implements TagFactory
'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead', 'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead',
'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property', 'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property',
'property-write' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite', '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', 'see' => '\phpDocumentor\Reflection\DocBlock\Tags\See',
'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since', 'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since',
'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source', 'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source',
@@ -17,9 +17,11 @@ use phpDocumentor\Reflection\DocBlock\Tags\Author;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter; use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter; use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
use phpDocumentor\Reflection\DocBlock\Tags\Generic; use phpDocumentor\Reflection\DocBlock\Tags\Generic;
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
use phpDocumentor\Reflection\DocBlock\Tags\See; use phpDocumentor\Reflection\DocBlock\Tags\See;
use phpDocumentor\Reflection\Fqsen; use phpDocumentor\Reflection\Fqsen;
use phpDocumentor\Reflection\FqsenResolver; use phpDocumentor\Reflection\FqsenResolver;
use phpDocumentor\Reflection\TypeResolver;
use phpDocumentor\Reflection\Types\Context; use phpDocumentor\Reflection\Types\Context;
/** /**
@@ -322,4 +324,35 @@ class StandardTagFactoryTest extends \PHPUnit_Framework_TestCase
$tagFactory->registerTagHandler('my-tag', 'stdClass'); $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());
}
} }