Skip to content

Commit

Permalink
PhpDocExtractor::getTypes() throws fatal error when type omitted
Browse files Browse the repository at this point in the history
  • Loading branch information
jfdialogs authored and fabpot committed Feb 7, 2018
1 parent a48849e commit 54253ec
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
Expand Up @@ -131,7 +131,9 @@ public function getTypes($class, $property, array $context = array())
$types = array();
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
foreach ($docBlock->getTagsByName($tag) as $tag) {
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
if ($tag && null !== $tag->getType()) {
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
}
}

if (!isset($types[0])) {
Expand Down
Expand Up @@ -40,6 +40,11 @@ public function testExtract($property, array $type = null, $shortDescription, $l
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
}

public function testParamTagTypeIsOmitted()
{
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
}

/**
* @dataProvider typesWithCustomPrefixesProvider
*/
Expand Down Expand Up @@ -176,3 +181,13 @@ class EmptyDocBlock
{
public $foo;
}

class OmittedParamTagTypeDocBlock
{
/**
* @param $omittedTagType
*/
public function setOmittedType(array $omittedTagType)
{
}
}

0 comments on commit 54253ec

Please sign in to comment.