Skip to content

Generic/ScopeIndent: don't flag comments between stacked case statements - #1468

Open
lazerg wants to merge 1 commit into
PHPCSStandards:4.xfrom
lazerg:fix/issue-1460-scopeindent-case-comments
Open

Generic/ScopeIndent: don't flag comments between stacked case statements#1468
lazerg wants to merge 1 commit into
PHPCSStandards:4.xfrom
lazerg:fix/issue-1460-scopeindent-case-comments

Conversation

@lazerg

@lazerg lazerg commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

Description

Generic.WhiteSpace.ScopeIndent flagged the indentation of a comment placed between two stacked case/default labels that share a body. It expected the comment to line up with the case body instead of with the labels.

The sniff already drops the indent it checks once it reaches a fall-through case/default label, but a comment sitting right before such a label was still checked against the previous case's body indent. It now checks against the label indent, so a comment aligned with the labels no longer errors, and a comment at the body indent still passes too.

Suggested changelog entry

Fixed:

  • Generic.WhiteSpace.ScopeIndent: a comment between stacked case/default statements is no longer flagged as incorrectly indented.

Related issues/external references

Fixes #1460

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
    • This change is only breaking for integrators, not for external standards or end-users.
  • Documentation improvement

PR checklist

  • I have checked there is no other PR open for the same change.
  • I have read the Contribution Guidelines.
  • I grant the project the right to include and distribute the code under the BSD-3-Clause license (and I have the right to grant these rights).
  • I have added tests to cover my changes.
  • I have verified that the code complies with the projects coding standards.
  • [Required for new sniffs] I have added XML documentation for the sniff.
  • I have opened a sister-PR in the documentation repository to update the Wiki.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Stacked case Statements with Comments in Between Incorrectly Flagged Indentation

1 participant