-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Fix Squiz.Commenting.FunctionComment.InvalidNoReturn
false positive when return type is never
#3717
Conversation
… when return type is `never`
@axlon Thanks for this PR. Could you please add some tests to cover this change ? Let me know if you have questions on how to do this. |
@jrfnl I managed to add the test, please let me know if anything needs changing 👍 |
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.
@axlon Thanks for adding that test. All looks good!
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.
@axlon I'm sorry, I spoke too soon. Looks like the tests are failing now. Could you please have a look ?
src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.inc
Outdated
Show resolved
Hide resolved
src/Standards/Squiz/Tests/Commenting/FunctionCommentUnitTest.php
Outdated
Show resolved
Hide resolved
@jrfnl I made the changes you requested, hope everything is ok, could you start the workflow for tests? Currently don't have a PHP 7.0 environment available to test on. EDIT: one thing I changed from before is that an error should now be emitted if a function has a documented return type of
|
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.
one thing I changed from before is that an error should now be emitted if a function has a documented return type of
never
but has a return statement (which already happened forvoid
functions). I couldn't figure out how write a test for this, could you point me in the right direction?------------------------------------------------------------------------------------------- FOUND 1 ERROR AFFECTING 1 LINE ------------------------------------------------------------------------------------------- 182 | ERROR | Function return type is never, but function contains return statement -------------------------------------------------------------------------------------------
This change evolves this PR from a bug fix to an enhancement and will definitely need more tests.
It also looks like this new part is unfinished as it doesn't seem to work the way it should ?
Could you please have another look at this ?
I think you are right, it definitely became a lot larger than I intended and I will need to immerse myself a bit more into writing tests for this library. I think I will revert this to only being a bugfix for now, and will follow up with a full fledged PR later. 👍 |
@jrfnl I think the PR is ready for review now |
@axlon Would you mind rebasing this PR (and possibly squashing the commits) to get it past the merge conflict ? |
@jrfnl Done! |
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.
Thanks @axlon ! The isolated bug fix, which this PR is now (again), looks good.
Just checking: do you intend to submit a PR for the follow-up which was discussed in the comments as well ?
@jrfnl Thanks! Yes, I still intend to create a followup PR whenever I find the time, but if someone else picks it up before me that is fine by me as well |
FYI: this fix is included in today's PHP_CodeSniffer 3.8.0 release. As per #3932, development on PHP_CodeSniffer will continue in the PHPCSStandards/PHP_CodeSniffer repository. If you want to stay informed, you may want to start "watching" that repo (or watching releases from that repo). |
The
Squiz.Commenting.FunctionComment.InvalidNoReturn
causes false positives when it encounters thenever
return type.Tested this locally with: