Skip to content

Commit

Permalink
[PropertyInfo] Fix a BC break when the DocBlock is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Feb 29, 2016
1 parent c55baba commit d2d8d17
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 12 deletions.
28 changes: 16 additions & 12 deletions src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
Expand Up @@ -193,21 +193,25 @@ private function getDocBlock($class, $property)

$ucFirstProperty = ucfirst($property);

switch (true) {
case $docBlock = $this->getDocBlockFromProperty($class, $property):
$data = array($docBlock, self::PROPERTY, null);
break;
try {
switch (true) {
case $docBlock = $this->getDocBlockFromProperty($class, $property):
$data = array($docBlock, self::PROPERTY, null);
break;

case list($docBlock) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::ACCESSOR):
$data = array($docBlock, self::ACCESSOR, null);
break;
case list($docBlock) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::ACCESSOR):
$data = array($docBlock, self::ACCESSOR, null);
break;

case list($docBlock, $prefix) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::MUTATOR):
$data = array($docBlock, self::MUTATOR, $prefix);
break;
case list($docBlock, $prefix) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::MUTATOR):
$data = array($docBlock, self::MUTATOR, $prefix);
break;

default:
$data = array(null, null, null);
default:
$data = array(null, null, null);
}
} catch (\InvalidArgumentException $e) {
$data = array(null, null, null);
}

return $this->docBlocks[$propertyHash] = $data;
Expand Down
Expand Up @@ -70,4 +70,14 @@ public function typesProvider()
array('donotexist', null, null, null),
);
}

public function testReturnNullOnEmptyDocBlock()
{
$this->assertNull($this->extractor->getShortDescription(EmptyDocBlock::class, 'foo'));
}
}

class EmptyDocBlock
{
public $foo;
}

0 comments on commit d2d8d17

Please sign in to comment.