Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 54253ec

Browse filesBrowse files
jfdialogsfabpot
authored andcommitted
PhpDocExtractor::getTypes() throws fatal error when type omitted
1 parent a48849e commit 54253ec
Copy full SHA for 54253ec

File tree

2 files changed

+18
-1
lines changed
Filter options

2 files changed

+18
-1
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ public function getTypes($class, $property, array $context = array())
131131
$types = array();
132132
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
133133
foreach ($docBlock->getTagsByName($tag) as $tag) {
134-
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
134+
if ($tag && null !== $tag->getType()) {
135+
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
136+
}
135137
}
136138

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

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public function testExtract($property, array $type = null, $shortDescription, $l
4040
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
4141
}
4242

43+
public function testParamTagTypeIsOmitted()
44+
{
45+
$this->assertNull($this->extractor->getTypes(OmittedParamTagTypeDocBlock::class, 'omittedType'));
46+
}
47+
4348
/**
4449
* @dataProvider typesWithCustomPrefixesProvider
4550
*/
@@ -176,3 +181,13 @@ class EmptyDocBlock
176181
{
177182
public $foo;
178183
}
184+
185+
class OmittedParamTagTypeDocBlock
186+
{
187+
/**
188+
* @param $omittedTagType
189+
*/
190+
public function setOmittedType(array $omittedTagType)
191+
{
192+
}
193+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.