The 2.6.0 release introduced composer-based sets. This release finishes the job: every extension package now ships a single composer-based set, and the per-version set providers behind the old guessing game are gone.
use Rector\Config\RectorConfig;
return RectorConfig::configure()
->withComposerBased(
doctrine: true,
phpunit: true,
twig: true,
);Each rule inside checks composer.json/installed.json on its own and runs only if the installed package version matches its constraint. No SymfonySetList::SYMFONY_63, no picking a PHPUnit version by hand. We're working hard to bring Drupal and Laravel community packages to the same system.
Run only the PHP rules (#8322)
A new --php option on the process command runs only rules bound to a minimal PHP version — those implementing MinPhpVersionInterface. Useful to split a PHP upgrade from the rest, without a second config:
vendor/bin/rector process src --php --dry-runNew features 🥳
- [Process] Add
--phpoption to run only PHP version rules (#8322) - [Configuration] Resolve the composer-based set of extension packages in
withComposerBased()(#8332), load Doctrine and Twig composer-based sets (#8313) - [Configuration] Report explicit error when the
--onlyrule exists but is not registered inrector.php(#8300) - [DX] Warn on skipped classes that are not Rector rules (#8323), include the skipped class name in the message (#8325)
- [DX] Show previous exceptions during bootstrap (#8287)
[WARNING] This skipped class is not a Rector rule, so it can never be skipped.
Only classes that implement "Rector\Contract\Rector\RectorInterface"
can be used in "->withSkip()"
New rules 🎉
rector-src
- [DeadCode]
RemoveRedundantTypeCheckRector(#8307)
$securityExpression = $operation->getSecurity();
-if (null === $securityExpression || ! is_string($securityExpression)) {
+if (null === $securityExpression) {
return;
}rector-symfony
- [Configs]
EnableValidationAttributesRector(#1004) - [Symfony 2.8] Rename
Simple(Pre|Form)AuthenticatorInterfacefromCoretoHttpnamespace (#1031)
rector-phpunit
- [PHPUnit 12.0]
AnyMatcherToNewAnyInvokedCountRectorfor the deprecatedany()matcher (#764)
Bugfixes 🐛
- [VersionBonding] Cap polyfill rules by the explicitly picked
withPhpSets()version (#8315) —withPhpSets(php82: true)withsymfony/polyfill-php83installed no longer produces PHP 8.3 code - [CodeQuality] Skip
InlineConstructorDefaultToPropertyRectoron non-final class (#8310) and on a property defined in the parent whenparent::__construct()is called (#8297) - [CodeQuality] Skip
SimpleXMLElementonIssetOnPropertyObjectToPropertyExistsRector(#8284) - [DeadCode] Skip
RemoveParentDelegatingConstructorRectoron protected parent constructor (#8309) - [DeadCode] Skip
assert()enforcement that producesNeverTypeonNarrowWideUnionReturnTypeRector(#8282) - [Php71] Skip
AssignArrayToStringRectoron a variable re-assigned as string (#8293) - [Php81] Skip
ArrayToFirstClassCallableRectorwhen the arg type does not accept aClosure(#8288), drop the Symfony PHP closure check (#8291)
Set changes 📈
- [Php84] Remove
DeprecatedAnnotationToDeprecatedAttributeRectorfrom the PHP 8.4 set and polyfills (#8326) - [Php83] Remove
AddOverrideAttributeToOverriddenMethodsRectorfrom the PHP 8.3 and polyfill sets (#8321) - [CodeQuality] Move 4 early-return rules to the code quality set (#8301)
- [DeadCode] Move
RemoveReadonlyPropertyVisibilityOnReadonlyClassRector(#8289),SimplifyBoolIdenticalTrueRectorandUnwrapSprintfOneArgumentRector(#8285) to the dead-code set - [rector-symfony] Convert the last version sets to the composer-based set (#1021), drop per-version composer-triggered sets (#1010), remove unused version-based set constants and configs (#1019)
- [rector-phpunit] Move every per-version rule into the composer-based set (#758), remove per-version set configs and constants (#760), register
PropertyExistsWithoutAssertRectorin the composer-based set (#761) - [rector-symfony] Add JMS attribute rules to the set, bond three attribute rules to package versions (#1029)
Deprecations 💀
Deprecated rules run without any effect, and print a warning and will be removed in a future major release.
These were deprecated as not part of any set, risky, opinionated or excluded by most users. The goal is to keep Rector valuable and reliable for the every day user.
rector-src
DeprecatedAnnotationToDeprecatedAttributeRectorandConstAndTraitDeprecatedAttributeRector(#8347)AddInterfaceByTraitRector(#8346)RemoveAnnotationRector(#8345)ScalarValueToConstFetchRector(#8344)FuncCallToMethodCallRector(#8343)AddReturnArrayDocblockBasedOnArrayMapRector(#8342)AddAssertArrayFromClassMethodDocblockRector(#8341)AddParamArrayDocblockBasedOnArrayMapRector(#8340)AddReturnDocblockForDimFetchArrayFromAssignsRector(#8338)AddSensitiveParameterAttributeRector(#8337)PropertyHookRector— property hooks are a matter of preference (#8331)JsonThrowOnErrorRector— can cause BC breaks (#8327)CoalesceToTernaryRector— risky (#8324)- [EarlyReturn]
ChangeNestedIfsToEarlyReturnRector(#8304),ChangeNestedForeachIfsToEarlyContinueRector(#8303),ReturnBinaryOrToEarlyReturnRector(#8302),ChangeOrIfContinueToMultiContinueRector(#8299) - [Strict]
DisallowedEmptyRuleFixerRector(#8290) - [Php85]
NestedFuncCallsToPipeOperatorRectorandSequentialAssignmentsToPipeOperatorRector(#8286) - [CodeQuality]
SwitchNegatedTernaryRector(#8283) cacheClass()— the file-vs-memory cache storage choice moved intoCacheFactory; onlyFileCacheStorageis ever useful to end users (#8311)symfonyRouteandsymfonyValidatorargs inwithAttributesSets()(#8317)ComposerTriggeredSetin favor ofComposerPackageConstraintInterface(#8296)withComposerBased(netteUtils:)argument (#8329)
rector-symfony
ActionSuffixRemoverRector(#1022)ControllerMethodInjectionToConstructorRector(#1020)TraitGetByTypeToInjectRector(#1002)RemoveDefaultGetBlockPrefixRector(#1017)- SwiftMailer to Symfony Mailer set (#1026)
rector-doctrine
RemoveEmptyTableAttributeRector(#505)MoveCurrentDateTimeDefaultInEntityToConstructorRector, drop theforce_nullableoption (#504)
Removals 💀
- Drop the
nette/utilsset and its singleUtilsJsonStaticCallNamedArgRectorrule (#8329) — the only third-party-library rule left in rector-src, readability only - Remove deprecated
NewInInitializerRector(#8328) - [Sets] Remove the PHP and core set providers (#8320), the Symfony per-version providers (#8292),
SymfonySetProvider,PHPUnitSetProvider(#8295) andDoctrineSetProvider(#8298) from the collector - [rector-symfony] Remove
TwigSetProvider(#1015) and the empty Symfony per-version set providers (#1012) - [rector-phpunit] Remove deprecated
PHPUnitSetProvider(#759) - [rector-doctrine] Remove
DoctrineSetProvider(#501), drop the unusedsymfony/yamldependency (#500)
rectorphp/rector-symfony 🎵
- [Symfony 7.3] Merge
AsTwigFilter/AsTwigFunctionrules into a single rule, addgetTests()support (#1027), restore the merged rules as deprecated (#1028) - [CodeQuality]
ControllerMethodInjectionToConstructorRector: re-use the parent protected property (#1003), skip event and session params (#1005), use#[Required]autowire()when the parent has a constructor (#1006), skip type-guarded classes and use a unique autowire method name (#1007), re-use an existing#[Required]method (#1008) - [CodeQuality]
LoadValidatorMetadataToAttributeRector: skip non-constant constraint args (#1000) and constraints without their own constructor (#1001) - [Sets] Fix
AddParamTypeDeclarationto nullable types where the upstream param defaults to null (#1023) - [Symfony30] Skip methods without return in
GetRequestRector(#1013), move it to the Symfony 2.5 set (#1009) - [Twig] Fix truncated
Twig_Tests_EnvironmentTest_Extensionrename (#1016)
rectorphp/rector-phpunit 🧪
- [PHPUnit 6.0]
AddDoesNotPerformAssertionToNonAssertingTestRector: add the attribute directly and skip traits (#765), removeaddToAssertionCount()calls (#763), skip TwigIntegrationTestCasechildren (#762)
Internals and CI 🧰
- [Testing] Check fixtures use the
*.php.incsuffix, not bare*.inc(#8306) - [e2e] Trim low-value e2e tests, fold
--onlyquote variants, revive the orphaned rules-summary test (#8334), remove the attributes e2e test (#8333) - [Scripts] Add
list-non-composer-based-rules.php(#8276) - [ci] Bump
actions/checkoutto v5 for Node.js 24 (#8335), bump outdated actions to current majors (#8336), bump lock-threads, stale and typos actions (#8339)