Skip to content

[FEATURE] Configure Rector and Fractor with RectorSettings::apply() and FractorSettings::apply() - #152

Merged
Kanti merged 6 commits into
mainfrom
rector-apply
Nov 26, 2026
Merged

Kanti merged 6 commits into
mainfrom
rector-apply

Conversation

@Kanti

@Kanti Kanti commented Nov 25, 2026 •

Copy link
Copy Markdown
Member

For 12.1.0. A new way to configure Rector and Fractor in the projects, and no more per-version PHP set files.

New templates

return RectorSettings::apply()
    ->withSkip([
        //__DIR__ . '/src/Example',
    ]);
return FractorSettings::apply()
    ->withSkip([
        //__DIR__ . '/Resources/Private/Example',
    ]);

apply() creates the configuration builder (RectorConfig::configure(), FractorConfiguration::configure()), adds the shared configuration and returns it, so the project configures everything else on the builder. A project can also pass its own builder as the first parameter.

Changes

  • RectorSettings::apply(?RectorConfigBuilder $rectorConfig = null, bool $phpSets = true, bool $typo3 = true): parallel, cache in var/cache/rector, import names, all PHP files in git, the prepared sets deadCode, codeQuality, codingStyle, typeDeclarations, privatization, withPhpSets() (PHP version from require.php; without it withPhpSets(php8x: true) for the running PHP version), the TYPO3 sets up to the lowest TYPO3 version and the shared skips. phpSets: false lets a project call withPhpSets() with its own version (it can only be called once), typo3: false leaves out the TYPO3 sets.
  • FractorSettings::apply(?FractorConfigurationBuilder $fractorConfig = null): all files in git, the TYPO3 set, the rule for projects without TYPO3 and the TypoScript options.
  • Deprecated, removal in 13: RectorSettings::sets(), RectorSettings::skip(), FractorSettings::sets(), FractorSettings::rules(), FractorSettings::options(). apply() uses private methods, PHPStan reports calls of the deprecated methods in projects.
  • RectorSettings::sets() uses SetList::PHP_VERSION_BASED_SET (the set behind withPhpSets(), available since Rector 2.8.0) instead of LevelSetList::UP_TO_PHP_* and SetList::PHP_*. No more constant() lookups and self-built paths to set files, no deprecation warnings of Rector 2.9 about per-version PHP sets, and no use of the deprecated LevelSetList.
  • RectorSettings::sets() and FractorSettings::sets() always contain all upgrades up to the versions; sets(false) is not used in any project and now triggers an E_USER_DEPRECATED.
  • RectorSettings::getLevel() is removed.
  • filterOutDeprecatedClasses() is removed: the tilde constraint allows only one minor version of Rector, so every skipped rule exists. The filter also dropped the skip of Configuration/ExtensionBuilder in TYPO3 projects, because it treated the path as a class name; that skip works now.
  • The packages no longer commit rector.php and fractor.php. They are in the .gitignore of the packages, the plugin creates them from the root templates on composer install. split.sh removes ignored files that are still in the package repositories, so the old rector.php disappears there with the next split.
  • README.md: Rector and Fractor sections describe apply(), which builder methods add and which replace, the deprecated methods and how to switch an older rector.php. New section "Using the templates unchanged": projects without changes of their own can delete rector.php/fractor.php and add them to .gitignore.
  • AGENTS.md, CONTRIBUTING.md: skips without filter, packages without rector.php, split step.
  • phpstan-baseline-without-typo3.neon: entries for the removed Typo3SetList::TYPO3_1x constants removed.

Compatibility

  • Existing rector.php and fractor.php files keep working; PHPStan reports the deprecated calls. The plugin creates these files only if they are missing, so only new projects get the new templates, or projects that delete them.
  • SetList::PHP_VERSION_BASED_SET contains all rules of the per-version PHP sets (checked in Rector 2.8.0 and 2.9.2) plus two PHP 5.2 rules; every rule is bound to its PHP version (MinPhpVersionInterface or ruleWithConfigurationPhpVersionBound()), so sets(true) behaves as before.
  • Builder methods: withSkip(), withSets() and withRules() add, withPaths(), withCache() and Fractor's withOptions() replace.

Notes

…nd FractorSettings::apply()

The templates now pass the configuration builder of Rector and Fractor to
apply(), which adds the shared configuration and returns it. Projects
configure everything else on the builder.

apply() uses the PHP sets of withPhpSets() instead of the per-version set
files, which Rector 2.9 deprecates, and the TYPO3 sets up to the lowest
TYPO3 version. RectorSettings::sets() uses SetList::PHP_VERSION_BASED_SET
instead of LevelSetList and SetList::PHP_*; its $entirety parameter and
the one of FractorSettings::sets() are ignored, the sets always contain
all upgrades. Older rector.php and fractor.php files keep working.

RectorSettings::getLevel() is deprecated and will be removed in 13.
… PHP requirement

Rector removed the unused $entirety parameter of sets(); passing false now
triggers a deprecation instead. withPhpVersion() only accepts the
PhpVersion constants, so the fallback without require.php calls
withPhpSets() with the version that runs Rector.
…per methods

RectorSettings::apply() and FractorSettings::apply() create the builder with RectorConfig::configure() and FractorConfiguration::configure() when none is passed, the templates call apply() without arguments.

RectorSettings::sets(), RectorSettings::skip(), FractorSettings::sets(), FractorSettings::rules() and FractorSettings::options() are deprecated, apply() uses private methods instead.

RectorSettings::getLevel() and filterOutDeprecatedClasses() are removed. The filter also removed the skip of Configuration/ExtensionBuilder, because it treated the path as a class name.
The packages no longer commit rector.php and fractor.php, they are ignored and the plugin creates them from the templates on composer install. split.sh removes ignored files that are still in the package repositories.
…ethods

The README explains how projects can keep rector.php and fractor.php out of git when they use the templates unchanged.
@Kanti
Kanti marked this pull request as ready for review November 26, 2026 08:58
@Kanti
Kanti merged commit c1558f2 into main Nov 26, 2026
82 checks passed
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.

1 participant