bug #25947 PhpDocExtractor::getTypes() throws fatal error when type omitted (Jared Farrish)
This PR was squashed before being merged into the 3.4 branch (closes #25947).
Discussion
----------
PhpDocExtractor::getTypes() throws fatal error when type omitted
| Q | A
| ------------- | ---
| Branch? | 3.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets |
| License | MIT
| Doc PR |
When omitting a type in a `DocBlock` `Tag`, it will throw a fatal error due to the type being null with a call to `$tag->getType()`.
Commits
-------
54253ecfff
PhpDocExtractor::getTypes() throws fatal error when type omitted
This commit is contained in:
commit
d068954458
@ -131,8 +131,10 @@ class PhpDocExtractor implements PropertyDescriptionExtractorInterface, Property
|
|||||||
$types = array();
|
$types = array();
|
||||||
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
|
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */
|
||||||
foreach ($docBlock->getTagsByName($tag) as $tag) {
|
foreach ($docBlock->getTagsByName($tag) as $tag) {
|
||||||
|
if ($tag && null !== $tag->getType()) {
|
||||||
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
|
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType()));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!isset($types[0])) {
|
if (!isset($types[0])) {
|
||||||
return;
|
return;
|
||||||
|
@ -40,6 +40,11 @@ class PhpDocExtractorTest extends TestCase
|
|||||||
$this->assertSame($longDescription, $this->extractor->getLongDescription('Symfony\Component\PropertyInfo\Tests\Fixtures\Dummy', $property));
|
$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
|
* @dataProvider typesWithCustomPrefixesProvider
|
||||||
*/
|
*/
|
||||||
@ -176,3 +181,13 @@ class EmptyDocBlock
|
|||||||
{
|
{
|
||||||
public $foo;
|
public $foo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class OmittedParamTagTypeDocBlock
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param $omittedTagType
|
||||||
|
*/
|
||||||
|
public function setOmittedType(array $omittedTagType)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user