Skip to content

Replace internal sniffs with PHPCSExtra Universal equivalents#55

Merged
dereuromark merged 1 commit intomasterfrom
feature/replace-sniffs-with-universal
Apr 10, 2026
Merged

Replace internal sniffs with PHPCSExtra Universal equivalents#55
dereuromark merged 1 commit intomasterfrom
feature/replace-sniffs-with-universal

Conversation

@dereuromark
Copy link
Copy Markdown
Contributor

Summary

Drops two internal sniffs in favor of their PHPCSExtra Universal counterparts, which are strict supersets of our implementations.

Removed Replacement
PhpCollective.ControlStructures.DisallowAlternativeControlStructures Universal.ControlStructures.DisallowAlternativeSyntax
PhpCollective.WhiteSpace.CommaSpacing Universal.WhiteSpace.CommaSpacing

Why Universal is a superset

DisallowAlternativeSyntax additionally provides:

  • Chained if/elseif/else fixed as a single unit (avoids fixer conflicts)
  • Proper else:} else { replacement
  • Optional allowWithInlineHTML for template code (default false — matches our behavior)
  • Per-construct error codes (FoundIf, FoundFor, …)
  • Metrics

CommaSpacing additionally provides:

  • CommaAfterComment fixer (moves the comma in front of trailing comments)
  • Modular error codes (InFunctionCall, InFunctionDeclaration, InClosureUse, InDeclare, InAttributeBlock)
  • Heredoc/nowdoc PHP-version-aware handling
  • Metrics

The one "extra" our internal CommaSpacingSniff did — stripping a trailing comma before ] in single-line arrays — is already covered by PhpCollective.PHP.DisallowTrailingCommaInSingleLine, so no functionality is lost.

Related to #53.

composer cs-check, composer test, composer stan and composer docs all pass locally.

Drop two internal sniffs in favor of their Universal counterparts which
are strict supersets:

- PhpCollective.ControlStructures.DisallowAlternativeControlStructures
  -> Universal.ControlStructures.DisallowAlternativeSyntax
- PhpCollective.WhiteSpace.CommaSpacing
  -> Universal.WhiteSpace.CommaSpacing

Universal adds chained if/elseif/else fixing, optional inline-HTML
allowance, trailing-comment handling, modular error codes and metrics.
The trailing-comma-before-] behavior previously folded into our
CommaSpacing sniff stays covered by DisallowTrailingCommaInSingleLine.
@dereuromark dereuromark force-pushed the feature/replace-sniffs-with-universal branch from 00bea18 to 24d3164 Compare April 10, 2026 15:36
@dereuromark dereuromark merged commit ac7444c into master Apr 10, 2026
4 checks passed
@dereuromark dereuromark deleted the feature/replace-sniffs-with-universal branch April 10, 2026 15:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant