Skip to content

[FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock #29569

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
Dec 17, 2018
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
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@

namespace Symfony\Bundle\FrameworkBundle\Console\Descriptor;

use phpDocumentor\Reflection\DocBlockFactory;
use phpDocumentor\Reflection\DocBlockFactoryInterface;
use Symfony\Component\Console\Descriptor\DescriptorInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\Alias;
Expand Down Expand Up @@ -293,21 +291,16 @@ protected function sortServiceIds(array $serviceIds)
public static function getClassDescription(string $class, string &$resolvedClass = null): string
{
$resolvedClass = $class;

if (!interface_exists(DocBlockFactoryInterface::class)) {
return '';
}

try {
$r = new \ReflectionClass($class);
$resolvedClass = $r->name;

if ($docComment = $r->getDocComment()) {
return DocBlockFactory::createInstance()
->create($docComment)
->getSummary();
$docComment = preg_split('#\n\s*\*\s*[\n@]#', substr($docComment, 3, -2), 2)[0];

return trim(preg_replace('#\s*\n\s*\*\s*#', ' ', $docComment));
}
} catch (\ReflectionException | \InvalidArgumentException $e) {
} catch (\ReflectionException $e) {
}

return '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,22 @@ public function getDescribeCallableTestData()
return $this->getDescriptionTestData(ObjectsProvider::getCallables());
}

/** @dataProvider getClassDescriptionTestData */
public function testGetClassDecription($object, $expectedDescription)
{
$this->assertEquals($expectedDescription, $this->getDescriptor()->getClassDescription($object));
}

public function getClassDescriptionTestData()
{
return array(
array(ClassWithDocCommentOnMultipleLines::class, 'This is the first line of the description. This is the second line.'),
array(ClassWithDocCommentWithoutInitialSpace::class, 'Foo.'),
array(ClassWithoutDocComment::class, ''),
array(ClassWithDocComment::class, 'This is a class with a doc comment.'),
);
}

abstract protected function getDescriptor();

abstract protected function getFormat();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,24 @@ class ClassWithoutDocComment
class ClassWithDocComment
{
}

/**
* This is the first line of the description.
* This is the second line.
*
* This is the third and shouldn't be shown.
*
* @annot should not be parsed
*/
class ClassWithDocCommentOnMultipleLines
{
}

/**
*Foo.
*
* @annot should not be parsed
*/
class ClassWithDocCommentWithoutInitialSpace
{
}
1 change: 0 additions & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
},
"suggest": {
"ext-apcu": "For best performance of the system caches",
"phpdocumentor/reflection-docblock": "For display additional information in debug:container",
"symfony/console": "For using the console commands",
"symfony/form": "For using forms",
"symfony/serializer": "For using the serializer service",
Expand Down