{"record":{"id":"bc95714b041e2e90","repo":"rectorphp/rector","slug":"the-withphpsets-method-uses-named-arguments","errorCode":null,"errorMessage":"The \"->withPhpSets()\" method uses named arguments. Its suitable for PHP 8.0+. Use \"->withPhpLevel()\" in lower PHP versions instead.","messagePattern":"The \"->withPhpSets\\(\\)\" method uses named arguments\\. Its suitable for PHP 8\\.0\\+\\. Use \"->withPhpLevel\\(\\)\" in lower PHP versions instead\\.","errorType":"exception","errorClass":"InvalidConfigurationException","httpStatus":null,"severity":"error","filePath":"src/Console/Notifier.php","lineNumber":27,"sourceCode":"use RectorPrefix202608\\Symfony\\Component\\Console\\Style\\SymfonyStyle;\nfinal class Notifier\n{\n    public static function notifyNotSuitableMethodForPHP74(string $calledMethod): void\n    {\n        if (\\PHP_VERSION_ID >= 80000) {\n            return;\n        }\n        $message = sprintf('The \"%s()\" method uses named arguments. Its suitable for PHP 8.0+. In lower PHP versions, use \"withSets([...])\" method instead', $calledMethod);\n        $symfonyStyle = new SymfonyStyle(new ArgvInput(), new ConsoleOutput());\n        $symfonyStyle->warning($message);\n        sleep(3);\n    }\n    public static function errorWithPhpSetsNotSuitableForPHP74AndLower(): void\n    {\n        if (\\PHP_VERSION_ID >= 80000) {\n            return;\n        }\n        throw new InvalidConfigurationException('The \"->withPhpSets()\" method uses named arguments. Its suitable for PHP 8.0+. Use \"->withPhpLevel()\" in lower PHP versions instead.');\n    }\n}\n","sourceCodeStart":9,"sourceCodeEnd":30,"githubUrl":"https://github.com/rectorphp/rector/blob/408fcb0ff1833e3d26cbc9b04c23a77565814a16/src/Console/Notifier.php#L9-L30","documentation":"withPhpSets() uses PHP 8.0 named arguments (php82: true), which cannot even be parsed by PHP 7.x. When Rector itself runs under PHP_VERSION_ID < 80000, Notifier::errorWithPhpSetsNotSuitableForPHP74AndLower() throws InvalidConfigurationException and directs you to withPhpLevel(), whose positional int argument works on every PHP version.","triggerScenarios":"A rector.php containing ->withPhpSets(php74: true) (or the no-argument form) executed by a PHP 7.4 interpreter, e.g. vendor/bin/rector resolved to a PHP 7.4 binary via composer config platform or a CI image pinned to 7.4.","commonSituations":"Legacy project pinned to PHP 7.4 where composer runs scripts with the project interpreter; developer's default php on PATH is old; CI matrix reuses a 7.4 job to run Rector for a still-supported branch.","solutions":["Replace withPhpSets(...) with withPhpLevel(\\Rector\\ValueObject\\PhpVersion::PHP_74) — a plain int argument valid on all PHP versions","Or execute Rector with a PHP 8+ binary while keeping the downgrade target: php8.1 vendor/bin/rector process","If staying on the old API, use withSets([LevelSetList::UP_TO_PHP_74]) with an explicit import"],"exampleFix":"// before\nreturn RectorConfig::configure()\n    ->withPhpSets(php74: true);\n\n// after\nuse Rector\\ValueObject\\PhpVersion;\n\nreturn RectorConfig::configure()\n    ->withPhpLevel(PhpVersion::PHP_74);","handlingStrategy":"validation","validationCode":"// choose API by interpreter, before loading rector.php\nif (PHP_VERSION_ID < 80000) {\n    // positional int works everywhere\n    $configurator->withPhpLevel(\\Rector\\ValueObject\\PhpVersion::PHP_74);\n} else {\n    $configurator->withPhpSets(php74: true);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin the RCTOR interpreter in CI: use a php:8.x image or an explicit php8.x binary for vendor/bin/rector","Prefer withPhpLevel() in shared configs so one file works under any PHP the team runs","Document the minimum PHP needed to RUN Rector separately from the PHP you TARGET for refactoring"],"tags":["php","rector","php-version","named-arguments","config"],"backgroundTag":"php-version-incompatibility","analyzedSha":"408fcb0ff1833e3d26cbc9b04c23a77565814a16","analyzedAt":"2026-08-21T05:11:02.643Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}