Skip to content

Commit d2d8d17

Browse files
committed
[PropertyInfo] Fix a BC break when the DocBlock is empty
1 parent c55baba commit d2d8d17

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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy