-
-
Notifications
You must be signed in to change notification settings - Fork 73
Squiz/FunctionComment: support DNF types #944
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
Squiz/FunctionComment: support DNF types #944
Conversation
9e7f936
to
da0fc7f
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.
@devfrey Thank you for this PR. Tested and confirmed working.
I just have one question: why did you change the condition order ?
As far as I can see, this makes no difference for the fix in this PR... ? And it does change the behaviour for an earlier test.
Other than that, please give credit where credit is due. As both the fix + the tests are literal copies of the original commit by @gsherwood, just in another sniff, it would be appropriate to add a Co-authored-by: Greg Sherwood <[email protected]>
tag.
Co-authored-by: Greg Sherwood <[email protected]>
da0fc7f
to
5f4e5d5
Compare
@jrfnl Hi Juliette, thanks for reviewing! I had to change the order of the conditions to make the tests pass for this example: /**
* @param $noTypeWithComment This parameter has no type specified.
* @return void
*/
Otherwise it would not report the missing type here. Since the first condition ( You say it changes behaviour for an earlier test, which one are you referring to? I've amended my commit message to include Greg. |
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've amended my commit message to include Greg.
Thanks for doing that @devfrey!
You say it changes behaviour for an earlier test, which one are you referring to?
When running:
phpcs -ps ./squiz/tests/commenting/functioncommentunittest.inc --standard=squiz --report=full,summary,source --sniffs=squiz.commenting.functioncomment
I'm seeing the following difference with vs without the patch:
- 794 | ERROR | [ ] Missing parameter name (Squiz.Commenting.FunctionComment.MissingParamName)
+ 794 | ERROR | [ ] Missing parameter type (Squiz.Commenting.FunctionComment.MissingParamType)
If I keep the change to the regex, but remove the order change, the diff becomes:
- 792 | ERROR | [ ] Missing parameter type (Squiz.Commenting.FunctionComment.MissingParamType)
+ 792 | ERROR | [ ] Missing parameter comment (Squiz.Commenting.FunctionComment.MissingParamComment)
- 1139 | ERROR | [ ] Missing parameter type (Squiz.Commenting.FunctionComment.MissingParamType)
+ 1139 | ERROR | [ ] Missing parameter comment (Squiz.Commenting.FunctionComment.MissingParamComment)
- 1145 | ERROR | [ ] Missing parameter type (Squiz.Commenting.FunctionComment.MissingParamType)
So, I see your point about line 1145. I've left a suggestion inline. AFAICS, with that applied, there is no difference in behaviour for the pre-existing tests, while the new tests still pass.
Co-authored-by: Juliette <[email protected]>
@jrfnl I've applied your suggestion, thank you for providing detailed steps! It definitely helped me understand what changed. |
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.
* Squiz/FunctionComment: support intersection types Co-authored-by: Greg Sherwood <[email protected]>
Old issues which may well be fixed by this (unverified - linking here for visibility in those issues): |
Description
If a doc comment contained an intersection type,
Squiz.Commenting.FunctionComment
would reportDoc comment for parameter "<param>" missing
. This PR fixes that. The updated regex was taken from a similar fix toPEAR.Commenting.FunctionComment
in f797a35.Suggested changelog entry
Squiz/FunctionComment: support intersection types
Related issues/external references
N/A
Types of changes
PR checklist
[Required for new sniffs] I have added XML documentation for the sniff.