-
-
Notifications
You must be signed in to change notification settings - Fork 61
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 generics in docblock #750
base: master
Are you sure you want to change the base?
Conversation
…Sniffer into feature/support-generics
Give me a moment to fix the conflicts |
Ref: #746 (comment) |
This may fail and if so I'll just have to work on this locally instead of blind through github. |
nevermind there are so many it didnt looking like they were working |
@tm1000 Thanks for this PR. I'm starting to review it now and noticed the PR template had been removed. I've taken the liberty to restore it and would like to ask you to fill in the missing bits & pieces (and maybe verify the bits I already filled in). |
@jrfnl sorry about that I did a quick copy and paste. Also I'll need to sit down and fix the pr issues At least it's here now. Finally :) |
No worries and I appreciate you porting the PR over.
I think the primary issue (which is failing the build) is a missing new line at the Expanding the tests a little more would also be good, but I'll go through the PR and will leave you a review.
Indeed ;-) |
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.
@tm1000 Thanks for this PR and for your willingness to contribute!
I've gone through the PR now and left a few comments inline.
Aside from that, as I mentioned in the issue, the tests will need to be expanded a bit. I'm thinking:
- Include the other examples from the code sample in the issue (Squiz.Commenting.FunctionComment.IncorrectTypeHint recognizes generics a part of type hints #746).
- And then have a second test with that same complete set, but then for a function which doesn't have type declarations yet. Even though the test setup as-is does not verify the message, having those tests there, still allows to verify (manually) that the message is now correct and also safeguards that the message will be thrown in those situations.
Other than that, I'd be happy to see this go into the codebase.
/** | ||
/** |
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 change. It doesn't belong with this PR and may have been there for a reason (as the sniff is about checking docblock formatting). Same for the fixed file.
*/ | ||
public function genericType(Collection $values) { | ||
|
||
}// end genericType() |
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 end the file on a new line char.
@tm1000 Just checking in to see whether you have a chance to update this PR based on the review. Would be great to get this merged. |
Description
This supports the following:
Where-as before it would say that the typehint needs to be
Collection<int, TelephoneNumber>
now it will correctly deduce that the type hint needs to beCollection
and will not return an errorI based this off of squizlabs/PHP_CodeSniffer#708 which is similar in scope.
Suggested changelog entry
Related issues/external references
Based off squizlabs/PHP_CodeSniffer#3544
Fixes squizlabs/PHP_CodeSniffer#3589
Fixes #746
Types of changes
PR checklist