New Universal.WhiteSpace.BackedEnumColonSpacing sniff#453
Open
rodrigoprimo wants to merge 1 commit into
Open
Conversation
…lon spacing Add the `Universal.WhiteSpace.BackedEnumColonSpacing` sniff which enforces the PER Coding Style 2.0 (section 9) spacing around the colon of a backed enum declaration: no space between the enum name and the colon, and a single space between the colon and the backing type. The amount of spacing on either side is configurable via the `spacingBefore` (default 0) and `spacingAfter` (default 1) properties. Fixes 443. Ref: https://github.com/php-fig/per-coding-style/blob/2.0.0/spec.md#9-enumerations
beec147 to
036df99
Compare
Collaborator
Author
|
Force-pushed without changes to re-trigger the GH Actions job that failed yesterday due to a temporary error. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This sniff checks the whitespace around the colon in a backed enum declaration.
The desired spacing before and after the colon is configurable via the
spacingBefore(defaults to no space) andspacingAfter(defaults to a single space) properties.The default values follow PER Coding Style 2.0, section 9: "When using a backed enum, there MUST NOT be a space between the enum name and colon, and there MUST be exactly one space between the colon and the backing type."
Non-backed enums are ignored.
Violations are reported under the
SpacingBeforeandSpacingAftererror codes and are auto-fixable in most cases.In #443, I suggested
EnumColonSpacingas the name of this sniff, but here I opted forBackedEnumColonSpacingto make it more explicit that this sniff only applies to backed enums.Fixes #443.
Suggested changelog entry
Universal.WhiteSpace.BackedEnumColonSpacingsniff to enforce consistent spacing around the colon in backed enum declarations.