Sometimes we want to run Rector on a subset of files only, e.g. just controllers or repositories. Instead of narrowing the paths in rector.php, we can use the --filter CLI option:
vendor/bin/rector process src --filter="/Controller/"
This keeps only files whose path or name matches the pattern. Three kinds of pattern are recognized:
/Controller/* glob matched against the file name, e.g. *Repository.phptests keyword - shortcut for Test.php and TestCase.php filesA glob that contains a / is matched against the full path, so these two are the same:
vendor/bin/rector process src --filter="/Controller/"
vendor/bin/rector process src --filter="*/Controller/*"
Pass a comma-separated list to require all patterns at once (AND):
vendor/bin/rector process src --filter="/tests/,*Test.php"
This keeps only *Test.php files that live under a /tests/ path.