cambis/silverstripe-rector

Rector rules for Silverstripe CMS.

Maintainers

👁 Cambis

Package info

github.com/Cambis/silverstripe-rector

pkg:composer/cambis/silverstripe-rector

Fund package maintenance!

Cambis

Statistics

Installs: 7 166

Dependents: 56

Suggesters: 1

Stars: 4

Open Issues: 0

v2.1.8 2026-01-16 00:49 UTC

Requires

Requires (Dev)

None

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT 7ee91cbd1646b568a03ab3b3a967abee22890517

  • Cameron Bryers

silverstripedevrector


README

This project contains Rector rules for Silverstripe CMS.

See the available Silverstripe rules.

Installation 👷‍♀️

Install via composer.

composer require --dev cambis/silverstripe-rector

Recommended 💡

Add PSR-4 autoload setup in your composer.json. This will help Rector to discover your classes and give it a performance boost.

{
 "autoload": {
 "classmap": [
 "app/src/Page.php",
 "app/src/PageController.php"
 ],
 "psr-4": {
 "MyProjectNamespace\\": "app/src"
 }
 },
 "autoload-dev": {
 "psr-4": {
 "MyProjectNamespace\\Tests\\": "app/tests"
 }
 }
}

Verify everything is compliant.

composer dumpautoload -o

Configuration 🚧

If you do not have an existing rector.php file, run the following command and Rector will create one for you.

vendor/bin/rector

Then use the SilverstripeLevelSetList and SilverstripeSetList sets and pick one of the constants.

<?php

declare(strict_types=1);

use Cambis\SilverstripeRector\Set\ValueObject\SilverstripeLevelSetList;
use Cambis\SilverstripeRector\Set\ValueObject\SilverstripeSetList;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
 ->withPaths([
 __DIR__ . '/app/_config.php',
 __DIR__ . '/app/src',
 __DIR__ . '/app/tests',
 ])
 ->withSets([
 SilverstripeLevelSetList::UP_TO_SILVERSTRIPE_52,
 SilverstripeSetList::CODE_QUALITY,
 ]);

Usage 🏃

Analyse your code with Rector and review the suggested changes.

vendor/bin/rector process --dry-run

Apply the suggested changes after they have been reviewed.

vendor/bin/rector process

For more information on usage, please refer to the official docs.