Skip to content

Commit

Permalink
bug #17965 [PropertyInfo] Fix a BC break when the DocBlock is empty (…
Browse files Browse the repository at this point in the history
…dunglas)

This PR was merged into the 3.1-dev branch.

Discussion
----------

[PropertyInfo] Fix a BC break when the DocBlock is empty

| Q             | A
| ------------- | ---
| Branch        | master
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

BC break introduced by #17531.

Commits
-------

d2d8d17 [PropertyInfo] Fix a BC break when the DocBlock is empty
  • Loading branch information
fabpot committed Mar 1, 2016
2 parents c55baba + d2d8d17 commit 41b2612
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 41b2612

Please sign in to comment.