fix(php-cs-fixer): switch @PSR12 → @PER-CS and bump migration preset to @PHP84Migration#286
Conversation
… 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>
There was a problem hiding this comment.
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:riskyto@PER-CS/@PER-CS:risky. - Bump migration preset from
@PHP83Migration+@PHP80Migration:riskyto@PHP84Migration+@PHP84Migration:risky.
There was a problem hiding this comment.
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.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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>
|


Summary
Two findings from the php-modernization skill validation run on
.php-cs-fixer.dist.php:@PSR12/@PSR12:riskysuperseded 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.@PHP83Migrationand@PHP80Migration:riskywhilecomposer.jsonpinsphp: ^8.5. Bumped to@PHP84Migration/@PHP84Migration:risky(the highest stable migration set in PHP-CS-Fixer; no@PHP85Migrationexists upstream yet).No
composer.jsonchanges needed:friendsofphp/php-cs-fixeris 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
vendor/bin/php-cs-fixer fix --dry-run --diff --config .php-cs-fixer.dist.phpreview (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)