-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
PhpDocExtractor::getTypes() throws fatal error when type omitted #25947
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
Conversation
I've worked with @userdude on this issue, so I won't change the status, but I too have experienced this bug and I can attest that this solution fixes it. |
This fix needs to go into the 3.3 branch. 3.2 is EOL. |
@@ -128,7 +128,9 @@ public function getTypes($class, $property, array $context = array()) | |||
$types = array(); | |||
/** @var DocBlock\Tags\Var_|DocBlock\Tags\Return_|DocBlock\Tags\Param $tag */ | |||
foreach ($docBlock->getTagsByName($tag) as $tag) { | |||
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType())); | |||
if ($tag && null !== $tag->getType()) { | |||
$types = array_merge($types, $this->phpDocTypeHelper->getTypes($tag->getType())); |
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 bug doest not exists in 2.7 ?
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.
It looks like PhpDocExtractor
was added in 2.8, and at that time it handled nulls (albeit differently).
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.
It may be a good idea to send an extra PR that adds this test case to the 2.8
branch to prevent regressions there.
moving to the 3.4 milestone as the last bugfix release for 3.3 was published today |
8b3f852
to
6f0a970
Compare
Rebased to 3.4, will try to add the 2.8 regression test as a separate PR but will be next week. |
class OmittedParamTagTypeDocBlock | ||
{ | ||
/** | ||
* @param $omittedTagType |
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 remove this docblock, it's not needed
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.
It's very much needed; it's the entire point of the test. Currently the PhpDocExtractor throws a fatal error when getting the type from a PHPDoc tag like this one.
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 believe a comment explaining the point would be valuable here, to prevent somebody "fixing" it later :)
Thank you @userdude. |
…mitted (Jared Farrish) This PR was squashed before being merged into the 3.4 branch (closes #25947). Discussion ---------- PhpDocExtractor::getTypes() throws fatal error when type omitted | Q | A | ------------- | --- | Branch? | 3.2 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | When omitting a type in a `DocBlock` `Tag`, it will throw a fatal error due to the type being null with a call to `$tag->getType()`. Commits ------- 54253ec PhpDocExtractor::getTypes() throws fatal error when type omitted
When omitting a type in a
DocBlock
Tag
, it will throw a fatal error due to the type being null with a call to$tag->getType()
.