Add Rector (relevant sets, aligned with PHPStan) and apply across the codebase#54
Merged
Conversation
Add rector/rector with a config aligned to this project's stack and the PHPStan level-8 + strict-rules setup: PHP-version sets, composer-based Symfony/PHPUnit rules, attribute sets, and the dead-code, code-quality, type-declaration, privatization, instanceof, early-return and Symfony/PHPUnit code-quality prepared sets. The Doctrine and Carbon sets are omitted — there is no domain Doctrine here (entities live in event-database-imports) and Carbon is not used. Coding style and imports remain owned by php-cs-fixer. Apply the resulting changes across src/ and tests/ (declare(strict_types), constructor promotion, typed constants, readonly classes, arrow-function return types, self:: → $this-> in tests, final test classes, …). The full suite (252), PHPStan (level 8 + strict + baseline) and php-cs-fixer all stay green. Wire it into `task code-analysis` (+ `code-analysis:rector[:apply]`) and add a Rector CI job to the Code Review workflow that fails on pending suggestions — the CI step event-database-imports omitted.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #54 +/- ##
=============================================
- Coverage 72.99% 72.89% -0.10%
Complexity 232 232
=============================================
Files 29 29
Lines 648 653 +5
=============================================
+ Hits 473 476 +3
- Misses 175 177 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Rector promoted the Tag/Vocabulary DTO constructors, so the generated schema now lists properties in constructor-parameter order (name, slug). Cosmetic property reorder only — not a breaking change.
# Conflicts: # CHANGELOG.md
|
# Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Mirrors event-database-imports #105 — adds Rector with the relevant sets aligned to our PHPStan level-8 + strict setup, applies it across the codebase, and (unlike importers) wires it into CI.
Changes
rector/rector: ^2.5(dev) andrector.php:withPhpSets(),withComposerBased(symfony: true, phpunit: true),withAttributesSets(symfony: true, phpunit: true).event-database-imports), Carbon unused. Coding style/imports stay owned by php-cs-fixer.src/andtests/(64 files):declare(strict_types=1), constructor promotion, typed constants,readonlyclasses, arrow-fn return types,self::→$this->in tests,finaltest classes, etc.task code-analysisnow runs PHPStan and Rector; addcode-analysis:rector(dry-run) andcode-analysis:rector:apply.rector process --dry-run) — the CI step importers omitted.Validation
rector process --dry-runis idempotent (clean after apply).FlipTypeControlToUseExclusiveTypeRector, which importers had to skip).Note
The new Rector check is not yet a required status check on
develop. Say the word and I'll add it to branch protection alongsidePHPStan static analysis.