-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[property-info] Detect invalid tags and throw error accordingly #36850
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
[property-info] Detect invalid tags and throw error accordingly #36850
Conversation
@nicolas-grekas Hi! Should I rebase this for branch 4.4 ? |
this looks like a bug fix to me, so yes please. Check 3.4 before, in case it makes sense on 3.4. |
composer.json
Outdated
@@ -100,7 +100,7 @@ | |||
"egulias/email-validator": "~1.2,>=1.2.8|~2.0", | |||
"symfony/phpunit-bridge": "^3.4.31|^4.3.4|~5.0", | |||
"symfony/security-acl": "~2.8|~3.0", | |||
"phpdocumentor/reflection-docblock": "^3.0|^4.0" | |||
"phpdocumentor/reflection-docblock": "^3.0||^4.0||^5.0" |
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.
please use a single |
for consistency
not the case anymore, failures are on all jobs :) |
@@ -83,6 +83,10 @@ public function getShortDescription($class, $property, array $context = []) | |||
} | |||
|
|||
foreach ($docBlock->getTagsByName('var') as $var) { | |||
if (is_a($var, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { |
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 (is_a($var, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { | |
if (is_a($var, InvalidTag::class)) { |
(add the appropriate use
too)
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.
The InvalidTag
is introduced in v5 of phpdocumentor/reflection-docblock. A use statement would be a BC break with v3 and v4 since those are autoloaded?
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.
no. Use statements don't imply that a class exist. And ::class
does not either (it is not an actual constant access on the class, but a compile-time thing)
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.
Ha I did't know that.
@@ -137,6 +141,10 @@ public function getTypes($class, $property, array $context = []) | |||
$types = []; | |||
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */ | |||
foreach ($docBlock->getTagsByName($tag) as $tag) { | |||
if (is_a($tag, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { |
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 (is_a($tag, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { | |
if (is_a($tag, InvalidTag::class)) { |
@@ -137,6 +141,10 @@ public function getTypes($class, $property, array $context = []) | |||
$types = []; | |||
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */ | |||
foreach ($docBlock->getTagsByName($tag) as $tag) { | |||
if (is_a($tag, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { | |||
return null; |
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.
Shouldn't we throw here too?
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.
Throwing here would break applications with invalid docblocks.
I'm doing this as a work in progress.
This PR:
Questions:
InvalidTag
class is not available ?InvalidArgumentException
, we ignore it, then the following tests are failing: