-
Notifications
You must be signed in to change notification settings - Fork 156
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
#162 Modified @deprecated validator to consider it valid if comment is absent but @see tag is set #181
Conversation
…mment is absent but @see tag is set
@sinisa86 unfortunately, only members of the maintainers team are allowed to assign developers to the pull request |
@sinisa86 unfortunately, only members of the maintainers team are allowed to assign developers to the pull request |
return true; | ||
if ($seeTagRequired) { | ||
return false; | ||
} else { |
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.
else
can be eliminated here.
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 we remove "else" branch there, it could lead to unexpected behavior because of the next IF condition:
if ($tokens[$seePtr + 2]['code'] !== T_DOC_COMMENT_STRING) { return false; }
That happens because $seePtr could be -1, so $seePtr + 2 points to how-knows-what.
"Else" part is required because it covers behavior when @see is not present at all.
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.
Actually, it really fails on some regular tests when I remove "else" branch.
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.
$seeTagRequired
is boolean and if it is false
, execution will drop to else
or directly to the return
.
I propose to simplify code even more:
$seePtr = $this->getTagPosition('@see', $commentStartPtr, $tokens);
if ($seePtr === -1) {
return !$seeTagRequired;
}
return $tokens[$seePtr + 2]['code'] === T_DOC_COMMENT_STRING;
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.
@sinisa86 could you please address review comments?
Done. |
@lenaorobei could you check this PR? |
- simplified logic
@sinisa86 thanks for this contribution and your patience! |
…sage AC-3187: Incorrect message for discouraged functions
Modified @deprecated validator to consider it valid if a comment is absent but @see tag is set.
see #162