Skip to content

Commit dd6a54a

Browse files
SerkanYildiznicolas-grekas
authored andcommitted
[FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock
1 parent 616b206 commit dd6a54a

File tree

4 files changed

+41
-12
lines changed

4 files changed

+41
-12
lines changed

Console/Descriptor/Descriptor.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;
1313

14-
use phpDocumentor\Reflection\DocBlockFactory;
15-
use phpDocumentor\Reflection\DocBlockFactoryInterface;
1614
use Symfony\Component\Console\Descriptor\DescriptorInterface;
1715
use Symfony\Component\Console\Output\OutputInterface;
1816
use Symfony\Component\DependencyInjection\Alias;
@@ -293,21 +291,16 @@ protected function sortServiceIds(array $serviceIds)
293291
public static function getClassDescription(string $class, string &$resolvedClass = null): string
294292
{
295293
$resolvedClass = $class;
296-
297-
if (!interface_exists(DocBlockFactoryInterface::class)) {
298-
return '';
299-
}
300-
301294
try {
302295
$r = new \ReflectionClass($class);
303296
$resolvedClass = $r->name;
304297

305298
if ($docComment = $r->getDocComment()) {
306-
return DocBlockFactory::createInstance()
307-
->create($docComment)
308-
->getSummary();
299+
$docComment = preg_split('#\n\s*\*\s*[\n@]#', substr($docComment, 3, -2), 2)[0];
300+
301+
return trim(preg_replace('#\s*\n\s*\*\s*#', ' ', $docComment));
309302
}
310-
} catch (\ReflectionException | \InvalidArgumentException $e) {
303+
} catch (\ReflectionException $e) {
311304
}
312305

313306
return '';

Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,22 @@ public function getDescribeCallableTestData()
195195
return $this->getDescriptionTestData(ObjectsProvider::getCallables());
196196
}
197197

198+
/** @dataProvider getClassDescriptionTestData */
199+
public function testGetClassDecription($object, $expectedDescription)
200+
{
201+
$this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object));
202+
}
203+
204+
public function getClassDescriptionTestData()
205+
{
206+
return array(
207+
array(ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'),
208+
array(ClassWithDocCommentWithoutInitialSpace::class, 'Foo.'),
209+
array(ClassWithoutDocComment::class, ''),
210+
array(ClassWithDocComment::class, 'This is a class with a doc comment.'),
211+
);
212+
}
213+
198214
abstract protected function getDescriptor();
199215

200216
abstract protected function getFormat();

Tests/Console/Descriptor/ObjectsProvider.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,3 +221,24 @@ class ClassWithoutDocComment
221221
class ClassWithDocComment
222222
{
223223
}
224+
225+
/**
226+
* This is the first line of the description.
227+
* This is the second line.
228+
*
229+
* This is the third and shouldn't be shown.
230+
*
231+
* @annot should not be parsed
232+
*/
233+
class ClassWithDocCommentOnMultipleLines
234+
{
235+
}
236+
237+
/**
238+
*Foo.
239+
*
240+
* @annot should not be parsed
241+
*/
242+
class ClassWithDocCommentWithoutInitialSpace
243+
{
244+
}

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@
8080
},
8181
"suggest": {
8282
"ext-apcu": "For best performance of the system caches",
83-
"phpdocumentor/reflection-docblock": "For display additional information in debug:container",
8483
"symfony/console": "For using the console commands",
8584
"symfony/form": "For using forms",
8685
"symfony/serializer": "For using the serializer service",

0 commit comments

Comments
 (0)