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 d068954

Browse filesBrowse files
committed
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 ------- 54253ec PhpDocExtractor::getTypes() throws fatal error when type omitted
2 parents 717e1c3 + 54253ec commit d068954
Copy full SHA for d068954

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.