-
-
Notifications
You must be signed in to change notification settings - Fork 480
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
Faulty core fixes: ScopeIndentSniff doesn't align a multiline comment correctly #1120
Comments
There's a similar issue with docblocks, given this example: <?php
function a() {
/**
* A docblock
*/
} The |
I'd need to check, but I seem to remember that is covered by one of the comment related sniffs in the In case that would be a stand-alone sniff, should it be moved to the |
Yah, I think it would need to be moved - the current |
@pento I've been looking into this. There is no isolated enough upstream sniff which can be used for the multi-line comments, however, for the docblock comments - as long as these are file/function/class/interfaces/property docblocks (i.e. not hook documentation docblocks) - the Want to have a try with that ? I'll have a think about writing a WPCS native sniff for multi-line comment alignment. My current line of thinking is: don't touch the first line (leave that to the How does that sound ? |
Unfortunately, I like the sound of the WPCS sniff behaviour. |
@pento Ok, thanks for the response. Leave it with me. |
@pento @DrewAPicture I have a question regarding multi-line non-docblock comments: |
I would consider it a hard rule. I actually can't think of any examples in
core that omit the leading asterisks in terms of PHP code unless it's
illustrating example code outside a docblock (can't say that I've seen any
though).
|
I think that the leading asterisks make things more readable, FWIW. |
@DrewAPicture @JDGrimes Thanks for your responses. I'm in favour of it being a hard-rule as well - even when it's for commented out code, which is where I most often see non-star |
@DrewAPicture Just wondering - should the handbook be adjusted to make it explicit that multi-line non-docblock comments should always have stars at the start of each line ? |
@pento FYI: part 1 (docblocks) is finished. Now working on part 2 (multi-line non-docblock comments). As we're working on the |
Yup, that works for me! |
@DrewAPicture Another question - regarding docblocks this time -: /** @var Database $mockedDatabase */
public $mockedDatabase; Or should it be fixed to: /**
* @var Database $mockedDatabase
*/
public $mockedDatabase; [Edit] Just thinking - even if not allowed in Core, I imagine some people in userland may prefer this format, so maybe we should by default auto-fix it, but allow that check to be bypassed with a |
I find that: /**
* @var Database $mockedDatabase
*/ is not currently sufficient for CS, and nor is: /**
* @var Database $mockedDatabase Description.
*/ It needs to be: /**
* Description.
*
* @var Database $mockedDatabase
*/ Not sure if that's intentional or not. (And it may just be some checks that PhpStorm is doing, outside of WPCS.) What the single-line formatting allows, is type hinting for the purposes of the IDE, when the variable appears in a method. |
@GaryJones In the Docs ruleset are other sniffs which would complain about there not being a short description for the property. I do not think this is something which can be auto-fixed. Moving the description up or adding an additional short description should be done by a dev. For now, I'm working on sniffs which will focus solely on the formatting of a docblock/ multi-line comment, not on the content. FYI - the formatting rules I'm currently implementing (based on the handbook and an inventerisation of this which I did nearly a year ago and which @DrewAPicture verified at the time): Docblocks:
Multi-line comments
|
A couple of notes:
When the docblock is in a location that requires no blank lines (for example, inside a function call), this causes clashes -
Short docblocks are allowed for duplicate hook dockblocks. |
I'll look into this.
I've changed the default value for |
FYI: The WIP branch which currently only contains the The I can pull the two sniffs separately, but these should be milestoned for |
Given the following example:
The comment will be indented, but the 2nd and 3rd line are missing the space to align their
*
correctly.The text was updated successfully, but these errors were encountered: