Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 75e91df

Browse files
committed
Fix for PhpDocExtractor::getTypes() throwing a fatal error when an omitting a type in @param tags.
1 parent fc9f947 commit 75e91df

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@ public function getTypes($class, $property, array $context = array())
128128
$types = array();
129129
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
130130
foreach ($docBlock->getTagsByName($tag) as $tag) {
131-
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
131+
if ($tag && $tag->getType() !== null) {
132+
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
133+
}
132134
}
133135

134136
if (!isset($types[0])) {

src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ public function testExtract($property, array $type = null, $shortDescription, $l
3939
$this->assertSame($shortDescription, $this->extractor->getShortDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
4040
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
4141
}
42+
43+
public function testParamTagTypeIsOmitted()
44+
{
45+
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
46+
}
4247

4348
public function typesProvider()
4449
{
@@ -85,3 +90,14 @@ class EmptyDocBlock
8590
{
8691
public $foo;
8792
}
93+
94+
class OmittedParamTagTypeDocBlock
95+
{
96+
/**
97+
* @param $omittedTagType
98+
*/
99+
public function setOmittedType(array $omittedTagType)
100+
{
101+
}
102+
103+
}

0 commit comments

Comments
 (0)