Skip to content

fix(php-cs-fixer): switch @PSR12 → @PER-CS and bump migration preset to @PHP84Migration#286

Merged
CybotTM merged 3 commits into
mainfrom
fix/per-cs-and-stale-migration-preset
May 7, 2026
Merged

fix(php-cs-fixer): switch @PSR12 → @PER-CS and bump migration preset to @PHP84Migration#286
CybotTM merged 3 commits into
mainfrom
fix/per-cs-and-stale-migration-preset

Conversation

@CybotTM
Copy link
Copy Markdown
Member

@CybotTM CybotTM commented May 7, 2026

Summary

Two findings from the php-modernization skill validation run on .php-cs-fixer.dist.php:

  • PM-05 (error)@PSR12 / @PSR12:risky superseded by @PER-CS / @PER-CS:risky. PER-CS (PHP Extended Recommendation Coding Style 3.0) extends PSR-12 and is the actively-maintained PHP-FIG coding-style ruleset. PHP-CS-Fixer 3.x ships both rulesets.
  • Stale migration preset — file used @PHP83Migration and @PHP80Migration:risky while composer.json pins php: ^8.5. Bumped to @PHP84Migration / @PHP84Migration:risky (the highest stable migration set in PHP-CS-Fixer; no @PHP85Migration exists upstream yet).

No composer.json changes needed: friendsofphp/php-cs-fixer is already constrained to ^3.65, which is the version that introduced @PHP84Migration.

All other rules (custom overrides, ordering tweaks, modernization rules) are unchanged.

Why

PER-CS is now the canonical PHP-FIG style ruleset; PSR-12 is frozen. The migration preset should match the project's runtime to surface modernization opportunities (PHP 8.4 readonly anonymous classes, asymmetric visibility hints, etc.).

Test plan

  • CI green
  • vendor/bin/php-cs-fixer fix --dry-run --diff --config .php-cs-fixer.dist.php review (reviewer checks the diff is acceptable; some auto-fixes may be larger than expected — local install required, vendor/ was not present in the working directory at PR creation time so the dry-run could not be executed)
  • No new PHPStan errors after the migration preset bump
  • Copilot review resolved

… to @PHP84Migration

Discovered during php-modernization skill validation run:
- @psr12 was superseded by @PER-CS (PHP Extended Recommendation Coding Style 3.0).
  PER-CS extends PSR-12 and is the actively-maintained PHP-FIG coding-style ruleset.
- @PHP83Migration / @PHP80Migration:risky are stale: this project pins PHP ^8.5
  in composer.json. Update to @PHP84Migration / @PHP84Migration:risky to apply
  PHP 8.4-tier modernizations (no @PHP85Migration ruleset exists yet upstream).

Source: https://github.com/netresearch/php-modernization-skill validation report.
Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings May 7, 2026 08:31
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the project’s PHP-CS-Fixer configuration to use the current PHP-FIG style preset (PER-CS) and align the migration ruleset with the project’s PHP runtime target (PHP 8.5 via the latest available @PHP84Migration preset).

Changes:

  • Switch preset from @PSR12 / @PSR12:risky to @PER-CS / @PER-CS:risky.
  • Bump migration preset from @PHP83Migration + @PHP80Migration:risky to @PHP84Migration + @PHP84Migration:risky.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the PHP CS Fixer configuration by transitioning from PSR-12 to PER-CS presets and upgrading PHP migration rules to version 8.4. A review comment identifies a potential issue with the significant jump to the PHP 8.4 risky preset, specifically warning that the automatically enabled readonly_class rule might interfere with Doctrine ORM proxies and should be carefully reviewed in the resulting diff.

Comment thread .php-cs-fixer.dist.php Outdated
@codecov
Copy link
Copy Markdown

codecov Bot commented May 7, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 81.49%. Comparing base (0d4c52f) to head (63172b0).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##               main     #286   +/-   ##
=========================================
  Coverage     81.49%   81.49%           
  Complexity     2579     2579           
=========================================
  Files           172      172           
  Lines          7107     7107           
=========================================
  Hits           5792     5792           
  Misses         1315     1315           
Flag Coverage Δ
integration 47.47% <ø> (ø)
unit 50.56% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

CybotTM added 2 commits May 7, 2026 10:42
CI failed with 'Set @PHP84Migration:risky does not exist'. PHP-CS-Fixer 3.95.1
ships the following risky migration sets: @PHP70Migration:risky,
@PHP71Migration:risky, @PHP74Migration:risky, @PHP80Migration:risky,
@PHP82Migration:risky. There is no @PHP83Migration:risky or
@PHP84Migration:risky preset upstream.

@PHP82Migration:risky is a strict superset of @PHP80Migration:risky (the
previous setting) and enables PHP 8.1/8.2-specific risky migrations
(notably readonly_class, as Gemini's review correctly flagged). The
non-risky @PHP84Migration set covers PHP 8.3/8.4 modernizations.

The diff produced by 'php-cs-fixer fix --dry-run --diff' under the new
ruleset should be reviewed before merging — readonly_class transforms
will touch every class that becomes eligible.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
php-cs-fixer fix output under the new ruleset. 80 changes across 11 test
files — all are PHP 8.4 chainable-new modernization:

  (new ClassName())->method()  ->  new ClassName()->method()

The pattern is enabled by the non-risky @PHP84Migration set (parens-omission
rule — 'new ClassWithoutArgs()->method()'). The transform is mechanical and
introduces no behavioral changes — the same chained call resolves to the
same method invocation on the same fresh instance.

config/reference.php was excluded via the existing notPath rule (it's
auto-generated by Symfony's config:dump-reference). The 11 modified files
are all pure source.

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented May 7, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
31.2% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@CybotTM CybotTM merged commit 0866048 into main May 7, 2026
22 of 24 checks passed
@CybotTM CybotTM deleted the fix/per-cs-and-stale-migration-preset branch May 7, 2026 08:58
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.

2 participants