Skip to content

Commit 8d24ce3

Browse files
committed
fix type mapping for return tag
1 parent ed4c6b7 commit 8d24ce3

File tree

2 files changed

+34
-1
lines changed

2 files changed

+34
-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: 33 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,35 @@ public function testHandlerRegistrationFailsIfProvidedHandlerDoesNotImplementThe
322324

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

0 commit comments

Comments
 (0)