[property-info] Detect invalid tags and throw error accordingly#36850
[property-info] Detect invalid tags and throw error accordingly#36850drupol wants to merge 4 commits intosymfony:3.4from drupol:36049-detect-invalid-tag-and-throw-error
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
| "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.
please use a single | for consistency
not the case anymore, failures are on all jobs :) |
| } | ||
|
|
||
| foreach ($docBlock->getTagsByName('var') as $var) { | ||
| if (is_a($var, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { |
There was a problem hiding this comment.
| 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.
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.
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)
| $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.
| if (is_a($tag, 'phpDocumentor\Reflection\DocBlock\Tags\InvalidTag')) { | |
| if (is_a($tag, InvalidTag::class)) { |
| /** @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.
Throwing here would break applications with invalid docblocks.
I'm doing this as a work in progress.
This PR:
Questions:
InvalidTagclass is not available ?InvalidArgumentException, we ignore it, then the following tests are failing: