8000 [PropertyInfo] Fix a BC break when the DocBlock is empty by dunglas · Pull Request #17965 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2016
Merged
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
[PropertyInfo] Fix a BC break when the DocBlock is empty
  • Loading branch information
dunglas committed Feb 29, 2016
commit d2d8d17a8068d76f42c42c7791f45ca68f4f98a4
28 changes: 16 additions & 12 deletions src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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