Skip to content

Add --php option to process command to run only PHP rules - #8322

Merged
TomasVotruba merged 2 commits into
mainfrom
add-php-only-option
Aug 8, 2026
Merged

Add --php option to process command to run only PHP rules#8322
TomasVotruba merged 2 commits into
mainfrom
add-php-only-option

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds a --php option to the process command, that runs only PHP rules - rules bound to a minimal PHP version, i.e. rules implementing MinPhpVersionInterface.

Useful to split a PHP version upgrade from the rest of the rules, without having to maintain a second config:

vendor/bin/rector process src --php --dry-run

Example

With a config combining PHP sets and other sets:

return RectorConfig::configure()
    ->withPaths([__DIR__ . '/src'])
    ->withPhpSets(php84: true)
    ->withPreparedSets(deadCode: true, codeQuality: true);

Running vendor/bin/rector process src --dry-run applies everything:

 class Demo
 {
-    public function run(string $value = null)
+    public function run(?string $value = null)
     {
-        $unused = 1;
-
         return $value;
     }
 }

Running vendor/bin/rector process src --php --dry-run keeps only the PHP version rules:

 class Demo
 {
-    public function run(string $value = null)
+    public function run(?string $value = null)
     {
         $unused = 1;
 
         return $value;
     }
 }

Downgrade rules are not affected, as they do not implement MinPhpVersionInterface.

Like --only and --composer-based, the option narrows the run, so unused skip reporting is disabled to avoid false positives. It is forwarded to workers in parallel runs.

TomasVotruba and others added 2 commits August 8, 2026 14:54
Runs only rules bound to a minimal PHP version, i.e. rules implementing
MinPhpVersionInterface. Useful to split a PHP version upgrade from the
rest of the rules in a single config.
@TomasVotruba
TomasVotruba merged commit 180a502 into main Aug 8, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the add-php-only-option branch August 8, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants