Repository navigation
[FEATURE] Configure Rector and Fractor with RectorSettings::apply() and FractorSettings::apply() - #152
Merged
Conversation
…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.
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.
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
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 invar/cache/rector, import names, all PHP files in git, the prepared setsdeadCode,codeQuality,codingStyle,typeDeclarations,privatization,withPhpSets()(PHP version fromrequire.php; without itwithPhpSets(php8x: true)for the running PHP version), the TYPO3 sets up to the lowest TYPO3 version and the shared skips.phpSets: falselets a project callwithPhpSets()with its own version (it can only be called once),typo3: falseleaves 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.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()usesSetList::PHP_VERSION_BASED_SET(the set behindwithPhpSets(), available since Rector 2.8.0) instead ofLevelSetList::UP_TO_PHP_*andSetList::PHP_*. No moreconstant()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 deprecatedLevelSetList.RectorSettings::sets()andFractorSettings::sets()always contain all upgrades up to the versions;sets(false)is not used in any project and now triggers anE_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 ofConfiguration/ExtensionBuilderin TYPO3 projects, because it treated the path as a class name; that skip works now.rector.phpandfractor.php. They are in the.gitignoreof the packages, the plugin creates them from the root templates oncomposer install.split.shremoves ignored files that are still in the package repositories, so the oldrector.phpdisappears there with the next split.README.md: Rector and Fractor sections describeapply(), which builder methods add and which replace, the deprecated methods and how to switch an olderrector.php. New section "Using the templates unchanged": projects without changes of their own can deleterector.php/fractor.phpand add them to.gitignore.AGENTS.md,CONTRIBUTING.md: skips without filter, packages withoutrector.php, split step.phpstan-baseline-without-typo3.neon: entries for the removedTypo3SetList::TYPO3_1xconstants removed.Compatibility
rector.phpandfractor.phpfiles 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_SETcontains 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 (MinPhpVersionInterfaceorruleWithConfigurationPhpVersionBound()), sosets(true)behaves as before.withSkip(),withSets()andwithRules()add,withPaths(),withCache()and Fractor'swithOptions()replace.Notes
LevelSetListdeprecation finding of [TASK] Require Rector with a caret constraint again #139 is gone; [TASK] Require Rector with a caret constraint again #139 then only waits for a release ofssch/typo3-rectorwith [BUGFIX] Ship own value objects removed in Rector 2.9 sabbelasichon/typo3-rector#4958.rectortask of GrumPHP).