8000 bug #17965 [PropertyInfo] Fix a BC break when the DocBlock is empty (… · symfony/symfony@41b2612 · GitHub
[go: up one dir, main page]

Skip to content

Commit 41b2612

Browse files
committed
bug #17965 [PropertyInfo] Fix a BC break when the DocBlock is empty (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
2 parents c55baba + d2d8d17 commit 41b2612

File tree

2 files changed

+26
-12
lines changed

2 files changed

+26
-12
lines changed

src/Symfony/Component/PropertyInfo/Extractor/PhpDocExtractor.php

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -193,21 +193,25 @@ private function getDocBlock($class, $property)
193193

194194
$ucFirstProperty = ucfirst($property);
195195

196-
switch (true) {
197-
case $docBlock = $this->getDocBlockFromProperty($class, $property):
198-
$data = array($docBlock, self::PROPERTY, null);
199-
break;
196+
try {
197+
switch (true) {
198+
case $docBlock = $this->getDocBlockFromProperty($class, $property):
199+
$data = array($docBlock, self::PROPERTY, null);
200+
break;
200201

201-
case list($docBlock) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::ACCESSOR):
202-
$data = array($docBlock, self::ACCESSOR, null);
203-
break;
202+
case list($docBlock) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::ACCESSOR):
203+
$data = array($docBlock, self::ACCESSOR, null);
204+
break;
204205

205-
case list($docBlock, $prefix) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::MUTATOR):
206-
$data = array($docBlock, self::MUTATOR, $prefix);
207-
break;
206+
case list($docBlock, $prefix) = $this->getDocBlockFromMethod($class, $ucFirstProperty, self::MUTATOR):
207+
$data = array($docBlock, self::MUTATOR, $prefix);
208+
break;
208209

209-
default:
210-
$data = array(null, null, null);
210+
default:
211+
$data = array(null, null, null);
212+
}
213+
} catch (\InvalidArgumentException $e) {
214+
$data = array(null, null, null);
211215
}
212216

213217
return $this->docBlocks[$propertyHash] = $data;

src/Symfony/Component/PropertyInfo/Tests/Extractors/PhpDocExtractorTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,14 @@ public function typesProvider()
7070
array('donotexist', null, null, null),
7171
);
7272
}
73+
74+
public function testReturnNullOnEmptyDocBlock()
75+
{
76+
$this->assertNull($this->extractor->getShortDescription(EmptyDocBlock::class, 'foo'));
77+
}
78+
}
79+
80+
class EmptyDocBlock
81+
{
82+
public $foo;
7383
}

0 commit comments

Comments
 (0)
0