rectorphp/rector · warning
The "->%s()" method is deprecated and no longer applied. Use
Error message
The "->%s()" method is deprecated and no longer applied. Use "->withPhpLevel()" instead, to raise PHP level one rule at a time.
What it means
This is a deprecation warning (printed via SymfonyStyle->warning, not an exception) emitted during a Rector run. The fluent config builder methods withPhp53Sets() through withPhp74Sets() no longer register any rules; calling them only records the method name (RectorConfigBuilder::reportDeprecatedPhpSetsMethod(), src/Configuration/RectorConfigBuilder.php:427-462) and at run time DeprecatedRulesReporter::reportDeprecatedPhpSetsMethods() prints this warning. Rector wants explicit per-version sets replaced by withPhpLevel()/withPhpSets(), which pick the target PHP level (from composer.json by default) instead of hard-coding a legacy version.
Source
Thrown at src/Reporting/DeprecatedRulesReporter.php:67
continue;
}
$this->symfonyStyle->warning(sprintf('Skipped rule "%s" is deprecated', $skippedRectorRule));
}
}
public function reportDeprecatedCacheMetaExtensions(): void
{
/** @var string[] $cacheMetaExtensions */
$cacheMetaExtensions = SimpleParameterProvider::provideArrayParameter(Option::CACHE_META_EXTENSIONS);
foreach ($cacheMetaExtensions as $cacheMetumExtension) {
$this->symfonyStyle->warning(sprintf('Cache meta extension "%s" is deprecated and no longer applied. It is a niche mechanism, let Rector handle cache on its own. If custom invalidation is needed, handle it in CI in a more generic way, e.g. by clearing the cache directory.', $cacheMetumExtension));
}
}
public function reportDeprecatedPhpSetsMethods(): void
{
/** @var string[] $deprecatedPhpSetsMethods */
$deprecatedPhpSetsMethods = SimpleParameterProvider::provideArrayParameter(Option::DEPRECATED_PHP_SETS_METHODS);
foreach (array_unique($deprecatedPhpSetsMethods) as $deprecatedPhpSetsMethod) {
$this->symfonyStyle->warning(sprintf('The "->%s()" method is deprecated and no longer applied. Use "->withPhpLevel()" instead, to raise PHP level one rule at a time.', $deprecatedPhpSetsMethod));
}
}
public function reportDeprecatedAttributesSetsArgs(): void
{
/** @var string[] $deprecatedAttributesSetsArgs */
$deprecatedAttributesSetsArgs = SimpleParameterProvider::provideArrayParameter(Option::DEPRECATED_ATTRIBUTES_SETS_ARGS);
foreach (array_unique($deprecatedAttributesSetsArgs) as $deprecatedAttributesSetsArg) {
$this->symfonyStyle->warning(sprintf('The "->withAttributesSets(%s: true)" argument is deprecated and no longer applied. It is already included in the "symfony: true" argument, use it instead.', $deprecatedAttributesSetsArg));
}
}
public function reportDeprecatedComposerBasedArgs(): void
{
/** @var string[] $deprecatedComposerBasedArgs */
$deprecatedComposerBasedArgs = SimpleParameterProvider::provideArrayParameter(Option::DEPRECATED_COMPOSER_BASED_ARGS);
foreach (array_unique($deprecatedComposerBasedArgs) as $deprecatedComposerBasedArg) {
$this->symfonyStyle->warning(sprintf('The "->withComposerBased(%s: true)" argument is deprecated and no longer applied. It only added named args to 2 methods of a single package, register the rule directly if needed.', $deprecatedComposerBasedArg));
}
}View on GitHub (pinned to 408fcb0ff1)
Solutions
- Replace the deprecated call: use ->withPhpLevel(PhpVersion::PHP_74) (or the level you targeted) so the exact set for that version is loaded again; add one withPhpLevel() per level if you previously stacked several withPhpXXSets() calls.
- Better: call ->withPhpSets() with no arguments so Rector derives the target PHP version from your composer.json require.php and stays current automatically.
- Remove the dead withPhpXXSets() lines entirely - keeping them does nothing (they register no rules) and only produces the warning.
- After the change, run `vendor/bin/rector process --dry-run` on a sample directory and diff the rule set (e.g. `vendor/bin/rector list` style dry run output) to confirm the expected level rules now actually apply.
Example fix
// before
return RectorConfigBuilder::create()
->withPaths([__DIR__ . '/src'])
->withPhp74Sets() // deprecated, no rules applied
->withRules([SomeRector::class]);
// after
use Rector\ValueObject\PhpVersion;
return RectorConfigBuilder::create()
->withPaths([__DIR__ . '/src'])
->withPhpLevel(PhpVersion::PHP_74)
->withRules([SomeRector::class]); Defensive patterns
Strategy: validation
Validate before calling
// CI pre-flight check: fail before the run if deprecated builder methods are still used
$configFile = 'rector.php';
$contents = file_get_contents($configFile);
foreach (['withPhp53Sets','withPhp54Sets','withPhp55Sets','withPhp56Sets','withPhp70Sets','withPhp71Sets','withPhp72Sets','withPhp73Sets','withPhp74Sets'] as $deprecatedMethod) {
if (str_contains($contents, $deprecatedMethod)) {
fwrite(STDERR, "rector.php uses deprecated builder {$deprecatedMethod}() - replace with withPhpLevel()/withPhpSets()\n");
exit(1);
}
} Prevention
- Prefer ->withPhpSets() with no arguments (level from composer.json) over hard-coded versions, so config never needs per-version methods.
- When copying Rector config recipes, check them against the version you install: withPhpXXSets() calls are pre-2.x style.
- Watch Rector's own output blocks during upgrades - warnings like this one are printed before diffs and indicate rules that silently stopped applying.
When it happens
Trigger: Calling ->withPhp53Sets(), withPhp54Sets(), withPhp55Sets(), withPhp56Sets(), withPhp70Sets(), withPhp71Sets(), withPhp72Sets(), withPhp73Sets() or withPhp74Sets() on the RectorConfigBuilder fluent chain in rector.php; the run starts normally but prints this warning block and those methods apply zero rules (so legacy-version downgrades/upgrade rules are silently NOT run).
Common situations: Projects on rector ^1.x (or rector-src 2.x) that still carry withPhpXXSets() calls from an older config recipe; teams noticing that PHP 5.x/7.x compatibility rules stopped applying after an upgrade and finding this warning in CI output; upgrading rector/downgrade-mirror tooling where old configs get copied forward.
Related errors
- "%s" rule is deprecated, as the #[Deprecated] attribute trig
- "%s" rule is deprecated, as the #[Deprecated] attribute trig
- Method "%s()" can be called only once. It always includes al
- E_USER_DEPRECATED
- "%s" rule is deprecated, as turning a docblock type into a r
AI-assisted analysis of rectorphp/rector@408fcb0ff1 (2026-08-21).
Data as JSON: /api/errors/62a82dcfde3e943a.
Report an issue: GitHub.