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

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
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()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bug doest not exists in 2.7 ?

Copy link
Author

@userdude userdude Jan 29, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like PhpDocExtractor was added in 2.8, and at that time it handled nulls (albeit differently).

f1eb185#diff-72b9199530f645acef692f3d77d4de4dR84

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It may be a good idea to send an extra PR that adds this test case to the 2.8 branch to prevent regressions there.

}
}

if (!isset($types[0])) {
Expand Down
Original file line number Diff line number Diff line change
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please remove this docblock, it's not needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's very much needed; it's the entire point of the test. Currently the PhpDocExtractor throws a fatal error when getting the type from a PHPDoc tag like this one.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a comment explaining the point would be valuable here, to prevent somebody "fixing" it later :)

*/
public function setOmittedType(array $omittedTagType)
{
}
}