Skip to content

Align phpcs.xml.dist / phpcbf.xml.dist with the PSR-12 standard so composer lint:fix stops mangling code #98

Description

@MaximillianGroup

Summary

PR #96 repointed the active lint gate (phpcs.xml, used by composer phpcs) from the full WordPress procedural standard to PSR-12 + a curated set of WordPress security/i18n sniffs, because the codebase is intentionally PSR-4 / PSR-12.

However, the .dist siblings were intentionally left untouched in that PR and still reference the old WordPress standard:

  • phpcbf.xml.dist — used by composer phpcbf (vendor/bin/phpcbf --standard=phpcbf.xml.dist ... src/)
  • phpcs.xml.dist — used by composer lint (vendor/bin/phpcs --standard=phpcs.xml.dist ... src/)

Why this matters

Running composer phpcbf, composer lint:fix, or the auto-fix CI job (.github/workflows/code-quality.yml) against the stale .dist standard will actively re-mangle modern code the way the original gate did:

  • []array()
  • forcing final on classes
  • Yoda conditions, tabs-vs-spaces churn
  • snake_case renames of the public PSR-4 API

That would undo the cleanup in #96 and reintroduce thousands of false "violations."

Proposed work

  1. Bring phpcs.xml.dist and phpcbf.xml.dist in line with the realigned phpcs.xml (PSR-12 base + the kept WordPress Security/DB/VIPMinimum/I18n/PrefixAllGlobals sniffs; drop the WP naming/filename/array-syntax conventions).
  2. Decide whether the .dist files should simply <rule ref="phpcs.xml"/>-style inherit, or be collapsed so there is a single source of truth for the standard.
  3. Re-verify composer phpcbf / composer lint:fix produce no destructive diffs on a clean src/ tree.
  4. Confirm the auto-fix job in code-quality.yml (runs phpcbf/phpfix/rector:fix on pushes to universe) is safe against the aligned standard.

Acceptance criteria

  • composer lint:fix on a clean tree yields only formatting that the PSR-12 gate also wants — no array() conversions, no forced final, no API renames.
  • composer lint and composer phpcs agree (same effective standard).

Scope note

Out of scope for PR #96 (which deliberately changed only the active read-only gate). Tracked here as the follow-up called out in that PR's "Out of scope" section.

https://claude.ai/code/session_017eY7AtjnwGHErQbDNzGxzt

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions