-
-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
[PropertyInfo] Get short description from promoted properties in PhpDocExtractor #59540
base: 7.3
Are you sure you want to change the base?
Conversation
This is a feature and should target 7.3 |
I don't know if this is really a feature because it works well with Beside, this code below points out that we support promoted properties:
|
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.
Can you update the changelog as well, as it's a feature?
@@ -95,6 +95,18 @@ public function getShortDescription(string $class, string $property, array $cont | |||
} | |||
} | |||
|
|||
foreach ($docBlock->getTagsByName('param') as $param) { |
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.
Can you update PhpStanExtractor
as well?
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.
Ok, I've looked at it and it seems it needs more work for PhpStanExtractor
than what I've done here.
So I propose to do it in another PR.
|
||
$paramDescription = $param->getDescription()?->render(); | ||
|
||
if (null !== $paramDescription && '' !== $paramDescription) { |
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 (null !== $paramDescription && '' !== $paramDescription) { | |
if ($paramDescription) { |
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.
Are you sure?
<?php
$paramDescription = '0';
echo $paramDescription ? 'ok' : 'ko'; // 'ko'
echo null !== $paramDescription && '' !== $paramDescription ? 'ok' : 'ko'; // 'ok'
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.
not sure 0
a useful description either
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.
Trimming 0
won't make it less predictable?
I mean in the way that, from the user point of view, we naturally expect that empty string or null can be skipped.
But other than these two cases, shouldn't we return what the user has input or is it what Symfony used to do for this kind of code?
If we skip 0
then I should add a test for it.
Looking at your code change this seems like it wasn't implemented before, there is no wrong behavior, the feature is just not existent, so a feature to me. |
I think the implementation would now read |
8a99cd3
to
f6c61c1
Compare
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.
Target branch changed to 7.3.
@@ -95,6 +95,18 @@ public function getShortDescription(string $class, string $property, array $cont | |||
} | |||
} | |||
|
|||
foreach ($docBlock->getTagsByName('param') as $param) { |
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.
Ok, I've looked at it and it seems it needs more work for PhpStanExtractor
than what I've done here.
So I propose to do it in another PR.
|
||
$paramDescription = $param->getDescription()?->render(); | ||
|
||
if (null !== $paramDescription && '' !== $paramDescription) { |
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.
Are you sure?
<?php
$paramDescription = '0';
echo $paramDescription ? 'ok' : 'ko'; // 'ko'
echo null !== $paramDescription && '' !== $paramDescription ? 'ok' : 'ko'; // 'ok'
Indeed, forgot about it, you can keep |
src/Symfony/Component/PropertyInfo/Tests/Fixtures/Extractor/PromotedPropertiesWithDocBlock.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/PropertyInfo/Tests/Extractor/PhpDocExtractorTest.php
Outdated
Show resolved
Hide resolved
|
||
$paramDescription = $param->getDescription()?->render(); | ||
|
||
if (null !== $paramDescription && '' !== $paramDescription) { |
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.
not sure 0
a useful description either
f6c61c1
to
9141b68
Compare
Currently this kind of phpdoc doesn't work to get description:
Whereas this one works: