-
Notifications
You must be signed in to change notification settings - Fork 62
api: setup rector again to keep our codebase up to date #7679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Exclude some controversial rules for now. This documents the rules which were used for the last run. No enforcement right now, just enablement. It also helped with fixing phpunit deprecations.
|
@CodeRabbit review this pr |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chainI'll help you review this PR! Let me gather the details about the changes first. 🏁 Script executed: Length of output: 178716 @BacLuc This is an excellent PR that modernizes your PHP codebase using Rector! Here's my comprehensive review: Overall Assessment ✅This PR demonstrates a thoughtful approach to automated refactoring. You've successfully:
Key Improvements1. Rector Configuration Modernization// Old format
return static function (ContainerConfigurator $containerConfigurator): void {
// ...
};
// New format
return RectorConfig::configure()
->withPaths([...])
->withPreparedSets(deadCode: true, codeQuality: true, ...)
->withSkip([...]);The new configuration is much cleaner and more maintainable. 2. Controller Method Names// Before
public function connectAction(Request $request, ClientRegistry $clientRegistry) {
// After
public function connect(Request $request, ClientRegistry $clientRegistry) {Removing the "Action" suffix follows modern Symfony conventions. 3. Code Quality ImprovementsBetter null checking: // Before: isset($data->campPrototype)
// After: null !== $data->campPrototypeSimplified array operations: // Before
$description = [];
$description['camp'] = [...];
return $description;
// After
return ['camp' => [...]];Modern type checking: // Before: is_a($data->category->rootContentNode, ColumnLayout::class)
// After: $data->category->rootContentNode instanceof ColumnLayout4. PHPUnit ModernizationData providers using generators: public static function invalidMethods(): \Iterator {
yield 'GET' => ['GET'];
yield 'PUT' => ['PUT'];
// ...
}Better assertions: // Before: assertEquals(12, count($data['_embedded']['contentNodes']))
// After: assertCount(12, $data['_embedded']['contentNodes'])Smart Rule SelectionYour
Minor Suggestions
Potential Concerns
Recommendation✅ Approve and merge - This is a well-executed modernization that significantly improves code quality while being conservative about controversial changes. The automated nature of these changes reduces the risk of introducing bugs while bringing the codebase up to modern PHP standards. Great work on the careful rule selection and systematic approach to code modernization! |
⛔ Feature branch deployment currently inactive.If the PR is still open, you can add the |
Exclude some controversial rules for now.
This documents the rules which were used for the last run. No enforcement right now, just enablement.
It also helped with fixing phpunit deprecations.