Skip to content

[FileSystem] Add --filter option to keep only files matching all given patterns - #8419

Merged
TomasVotruba merged 3 commits into
mainfrom
add-filter-option
Sep 1, 2026
Merged

[FileSystem] Add --filter option to keep only files matching all given patterns#8419
TomasVotruba merged 3 commits into
mainfrom
add-filter-option

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

Adds a --filter option to the process command, alongside the existing --only-suffix.

It keeps only files matching all comma-separated patterns (AND). Three pattern kinds:

  • tests - basename ends in Test.php or TestCase.php
  • contains * - glob matched against the basename, e.g. *Repository.php
  • anything else - substring matched anywhere in the full path, e.g. /Controller/
# only controllers
vendor/bin/rector process src --filter=/Controller/

# repositories that are also under /Domain/
vendor/bin/rector process src --filter=/Domain/,*Repository.php

# test files only
vendor/bin/rector process . --filter=tests

The selection is folded into the per-file cache scope, so filtered and full runs coexist without poisoning each other, same as --only-suffix. It also marks the run as narrowed, so unused-skip reporting stays off.

Makes --filter=*/Controller/* behave like --filter=/Controller/, so a glob
containing a "/" is matched against the full path instead of the basename.

Claude-Session: https://claude.ai/code/session_01J73DBF9SQvcgFnsBhr71cF
Emits a deprecation warning when --only-suffix is used and points users to
--filter, which covers the same case via --filter="*Controller.php".

Claude-Session: https://claude.ai/code/session_01J73DBF9SQvcgFnsBhr71cF
@TomasVotruba
TomasVotruba merged commit 0c3d4f4 into main Sep 1, 2026
44 checks passed
@TomasVotruba
TomasVotruba deleted the add-filter-option branch September 1, 2026 21:56
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.

1 participant