It should be possible to provide a command line option that causes rector to apply a single rule only.
Configuration file adjustments should not be necessary.
This is a feature needed for #8898 (automatically splitting up rector fixes into different commits).
History
rector once had such a parameter:
2019-06-23: --rule was added #1640
2020-01-14: --rule was renamed to --only #2655
2020-05-01: --only was removed with 9eaeb3053e6449bf2e6a871b3a9f0f65cd0b1daf
Hi, we actually had this feature few years ago. It was breaking very often as the rules discovery by short class name requires full autoload of all classes. Also you have to make sure there are no 2 short classes.
Due to that design, it caused more confusion than value, so we removed it.
Since the summer switch from YAML to PHP configs, the set optoins was also redisigned to be used purely in PHP. The set names from CLI were mismatched to their PHP names. The --set option CLI has been removed as well, so the config would be the single place to use
After this year's switch from YAML to PHP configs, and dropping --set CLI option to make use of the PHP configs, this feature is contradictory towards PHP autocomplete filosophy
Naming
--only (--rule was renamed to --only in #2655).
Accepted values
The option should accept a single value only: A fully qualified class name (not a short/relative one, see #7366).
Backslashes must be escaped differently in different shells and operating systems. Either document that or warn the user if the option value has no backslash in it.
Leading backslash required or not? I'd say not. Rules always must be fully namespaced; a missing leading backslash shall get added automatically.
Affected commands
process
list-rules
:exclamation: After reading the comments in the previous issues and patches, I have no idea what requirements regarding naming, functionality and stability you have for this feature.
Feature Request
It should be possible to provide a command line option that causes rector to apply a single rule only. Configuration file adjustments should not be necessary.
This is a feature needed for #8898 (automatically splitting up rector fixes into different commits).
History
rector once had such a parameter:
--rule
was added #1640--rule
was renamed to--only
#2655--only
was removed with 9eaeb3053e6449bf2e6a871b3a9f0f65cd0b1daf--only
was re-added #3539--only
was removed again #4701Problems
https://github.com/rectorphp/rector/issues/7366#issuecomment-1213551076:
https://github.com/rectorphp/rector/issues/3342#issuecomment-734404750:
https://github.com/rectorphp/rector/issues/3342#issuecomment-626539791
https://github.com/rectorphp/rector/issues/4699#issue-751723436
Naming
--only
(--rule
was renamed to--only
in #2655).Accepted values
The option should accept a single value only: A fully qualified class name (not a short/relative one, see #7366).
Things to consider:
Affected commands
process
list-rules
:exclamation: After reading the comments in the previous issues and patches, I have no idea what requirements regarding naming, functionality and stability you have for this feature.