Skip to content

Generic.WhiteSpace.ScopeIndent: Fix multi-line extends/implements indentation#1366

Open
jrchamp wants to merge 3 commits intoPHPCSStandards:4.xfrom
jrchamp:fix/interface-indentation
Open

Generic.WhiteSpace.ScopeIndent: Fix multi-line extends/implements indentation#1366
jrchamp wants to merge 3 commits intoPHPCSStandards:4.xfrom
jrchamp:fix/interface-indentation

Conversation

@jrchamp
Copy link

@jrchamp jrchamp commented Feb 3, 2026

Description

Scope indentation for multi-line declarations was not working. extends and implements are "children" of the oo scope tokens (for example, class/interface), so when they appear on a separate line, they were not being indented appropriately. Additionally, their "siblings", the name tokens were ignored or sometimes skipped completely.

This PR adds tests for multi-line OO Scope Tokens, adds logic so indentation is correctly checked, and reworks the logic that was causing anonymous class tokens to be skipped.

Suggested changelog entry

Generic.WhiteSpace.ScopeIndent: Fix multi-line extends/implements indentation

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.

Add tests for anonymous classes. This required a change to the
ScopeIndentSniff logic to not skip tokens when processing a multi-line
anonymous class definition. Thankfully there are many test cases already
to avoid regressions.
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.

1 participant