Filter Files
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:
- path substring - matched anywhere in the full path, e.g.
/Controller/ - basename glob -
*glob matched against the file name, e.g.*Repository.php testskeyword - shortcut forTest.phpandTestCase.phpfiles
A 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/*"
Combine multiple patterns
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.