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
[FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock #29569
[FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock #29569
Conversation
Thanks for submitting! During the SymfonyCon hackday last Saturday, someone worked exactly on this - except that they opened no PR so the code might be lost :) Here are my suggestions:
|
Hi @nicolas-grekas, It was me during the SymfonyCon who started with this patch. Will apply your comments and update this PR. Thanks for your review! |
$summary = str_replace( | ||
array('/', '*', "\t", "\r\n", "\n", "\r", ' '), | ||
'', | ||
substr($docComment, 0, strpos($docComment, '@')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seems very fragile (perhaps * @
works better). But tend to prefer an explicit regex to capture the short description as a sentence.
This captures both short+long description and removes newlines in between.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ro0NL Can you help me with a regex to get the description? Would be great!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SerkanYildiz something like https://regex101.com/r/Sqcmmf/1/
It matches the first sentence per https://github.com/php-fig/fig-standards/blob/master/proposed/phpdoc.md#51-summary
A Summary MUST end with two sequential line breaks, unless it is the only content in the PHPDoc.
The current regex does not include single new lines, e.g. short line 1\nshort line 2
would only match short line 1
. AFAIK it's OK.
->getSummary(); | ||
} | ||
} catch (\ReflectionException | \InvalidArgumentException $e) { | ||
$docComment = $r->getDocComment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if ($docComment = $r->getDocComment()) {
should be kept imho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-added the if statement thanks @nicolas-grekas
@ro0NL Your regex worked and made the tests pass (at least locally.) Thank You! |
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you please add tests with several variants of class descriptions (or missing ones)?
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
@nicolas-grekas I don't now if it's necessary to add more tests. There were existing tests for the old implementation. We just changed the logic and IMO we just had to ensure that the tests should still pass |
we should add a test for
resulting in and
resulting in |
@nicolas-grekas failing test is not related to this PR |
src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we're there :) last minor comments from me.
src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Console/Descriptor/Descriptor.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/ObjectsProvider.php
Outdated
Show resolved
Hide resolved
ping @nicolas-grekas , failing AppVeyor seems unrelated. Can we retrigger AppVeyor build? |
Thank you @SerkanYildiz. |
…ntor/reflection-docblock (SerkanYildiz) This PR was merged into the 4.2 branch. Discussion ---------- [FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock | Q | A | ------------- | --- | Branch? | 4.2 | Bug fix? | yes New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | / | License | MIT When phpDocumentor isn't installed the *debug:autowiring* returns an empty string for class description. With this fallback the end user will get a description even phpDocumentor isn't installed. **Edit:** Usage of phpDocumentor is completely removed from debug:autowiring command. Commits ------- 485ed4d [FrameworkBundle] decouple debug:autowiring from phpdocumentor/reflection-docblock
When phpDocumentor isn't installed the debug:autowiring returns an empty string for class description. With this fallback the end user will get a description even phpDocumentor isn't installed.
Edit: Usage of phpDocumentor is completely removed from debug:autowiring command.