Skip to content

Commit 0cc2b07

Browse files
committed
Merge pull request #60 from jaapio/fix/returntag
fix type mapping for return tag
2 parents ed4c6b7 + 6a6a4ca commit 0cc2b07

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

src/DocBlock/StandardTagFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ final class StandardTagFactory implements TagFactory
5454
'property-read' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyRead',
5555
'property' => '\phpDocumentor\Reflection\DocBlock\Tags\Property',
5656
'property-write' => '\phpDocumentor\Reflection\DocBlock\Tags\PropertyWrite',
57-
'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return',
57+
'return' => '\phpDocumentor\Reflection\DocBlock\Tags\Return_',
5858
'see' => '\phpDocumentor\Reflection\DocBlock\Tags\See',
5959
'since' => '\phpDocumentor\Reflection\DocBlock\Tags\Since',
6060
'source' => '\phpDocumentor\Reflection\DocBlock\Tags\Source',

tests/unit/DocBlock/StandardTagFactoryTest.php

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
use phpDocumentor\Reflection\DocBlock\Tags\Formatter;
1818
use phpDocumentor\Reflection\DocBlock\Tags\Formatter\PassthroughFormatter;
1919
use phpDocumentor\Reflection\DocBlock\Tags\Generic;
20+
use phpDocumentor\Reflection\DocBlock\Tags\Return_;
2021
use phpDocumentor\Reflection\DocBlock\Tags\See;
2122
use phpDocumentor\Reflection\Fqsen;
2223
use phpDocumentor\Reflection\FqsenResolver;
24+
use phpDocumentor\Reflection\TypeResolver;
2325
use phpDocumentor\Reflection\Types\Context;
2426

2527
/**
@@ -322,4 +324,38 @@ public function testHandlerRegistrationFailsIfProvidedHandlerDoesNotImplementThe
322324

323325
$tagFactory->registerTagHandler('my-tag', 'stdClass');
324326
}
327+
328+
/**
329+
* @covers ::create
330+
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::__construct
331+
* @uses phpDocumentor\Reflection\DocBlock\StandardTagFactory::addService
332+
* @uses phpDocumentor\Reflection\Docblock\Description
333+
* @uses phpDocumentor\Reflection\Docblock\Tags\Return_
334+
* @uses phpDocumentor\Reflection\Docblock\Tags\BaseTag
335+
*/
336+
public function testReturntagIsMappedCorrectly()
337+
{
338+
$context = new Context('');
339+
340+
$descriptionFactory = m::mock(DescriptionFactory::class);
341+
$descriptionFactory
342+
->shouldReceive('create')
343+
->once()
344+
->with('', $context)
345+
->andReturn(new Description(''))
346+
;
347+
348+
$typeResolver = new TypeResolver();
349+
350+
$tagFactory = new StandardTagFactory(m::mock(FqsenResolver::class));
351+
$tagFactory->addService($descriptionFactory, DescriptionFactory::class);
352+
$tagFactory->addService($typeResolver, TypeResolver::class);
353+
354+
355+
/** @var Return_ $tag */
356+
$tag = $tagFactory->create('@return mixed', $context);
357+
358+
$this->assertInstanceOf(Return_::class, $tag);
359+
$this->assertSame('return', $tag->getName());
360+
}
325361
}

0 commit comments

Comments
 (0)