-
-
Notifications
You must be signed in to change notification settings - Fork 69
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
[Documentation] PSR12 - Control Structure Spacing #182
[Documentation] PSR12 - Control Structure Spacing #182
Conversation
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 @dingo-d for taking this on!
Could you have a look at the inline comments please ?
Also - would it be an idea to have a separate standard
block for single line control structure conditions vs multi-line control structure conditions ?
And maybe a separate standard
block about the "each expression on its own line and indented once" rule ?
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Show resolved
Hide resolved
Yeah, I was wondering what would be the best way to split this documentation, as there are quite a bit of it. Will see how to best split it with separate |
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
Added emphasis as per PR review and added additional standards so that the documentation is easier to read (split by logic as suggested in the PR review).
@jrfnl Can you take another look? I've added the additional standards, so it should be more readable now. |
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.
@dingo-d Please have another look.
May I also ask you to have a critical look at your other open PRs based on the review comments you've received in this PR and others before this ?
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
</code> | ||
<code title="Invalid: Space after the opening parenthesis in a single-line condition."> | ||
<![CDATA[ | ||
if <em>( </em>$expr) { |
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.
Should the "no space after the keyword" rule get its own code sample ? Or could this be included in this invalid code sample ?
if <em>( </em>$expr) { | |
if<em> ( </em>$expr) { |
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.
Technically, this sniff doesn't check for the space after the keyword. This is covered by the Squiz.ControlStructures.ControlSignature.SpaceAfterKeyword
sniff, so I'm not sure if we should include it in the documentation for this sniff.
I'm all for removing squiz rules from the PSR12 ruleset, and just modifying the ControlStructuresSpacing
sniff to include all the checks as in the PSR-12 documentation for control structures, but I think that would be something for PHPCS v4.
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.
You are 100% correct! I thought this sniff was checking that too, but you are right, it does not. The updated standards description from commit a1795c1 confused me as that _does_mention the space after the control structure keyword.
In other words: No, there should not be a code sample for space after keyword, but the first <standard>
block will need to be updated to remove the mention of the spacing after the keyword.
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.
And this bit ", and one space between the closing parenthesis and the opening brace" will also need to be removed as that is also not checked via this sniff.
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.
Yes, you're right about these. Will fix them now 👍🏼
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
I think I now have this docs fixed @jrfnl. See my remark about the space after the keyword above. I'm also not 100% sure about the |
src/Standards/PSR12/Docs/ControlStructures/ControlStructureSpacingStandard.xml
Outdated
Show resolved
Hide resolved
…cingStandard.xml Co-authored-by: Juliette <[email protected]>
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 @dingo-d for working on this! Ready for merge 🎉
* Add the documentation for the PSR12 Control Structure Spacing sniff
The PR contains the documentation for the PSR12/ControlStructures/ControlStructureSpacing sniff.
Description
This PR will add the documentation for the above-mentioned sniff, according to the official standard definitions.
Note that some rules mentioned in the above definitions are covered by other rulesets. So they were not added to the documentation, as they are not a part of the Control Structure Spacing sniff.
Suggested changelog entry
Add documentation for the PSR12 ControlStructureSpacing sniff
Related issues/external references
Part of #148
Types of changes
PR checklist