-
-
Notifications
You must be signed in to change notification settings - Fork 673
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
A way to stop rector from changing unaffected files by importNames parameter #8649
Comments
I think you can have 2 kind of configs for that, eg:
then, in your return static function (RectorConfig $rectorConfig): void {
$rectorConfig->import(__DIR__ . '/rector.php');
$rectorConfig->importNames();
}; so you can run
or vice versa so you can review as another individual change. |
@samsonasik Sorry, but I don't understand how exactly it helps in my case. If I want to go throughout the code applying a rule that changes interface usage to an attribute (in my case - MessageHandlerInterfaceToAttributeRector), it will either A) [without importNames()] Update only the files I need but use annotation with the full namespace like this:
B) [with importNames()] It will add correct annotation with the short class name:
But it will also change full class name usages throughout all my code, which is huge. So, there is no option C) at the moment, where I'd get short class for the attribute, and it won't change all other files which I didn't want to affect. I don't understand how having 2 separate config files may help me. |
It was removed due to avoid too detailed setup and making ambiguous code, see PR: You can have as many config as needed for your use case, then run separately with Thank you for understanding. |
Is there an alternative for the removed
APPLY_AUTO_IMPORT_NAMES_ON_CHANGED_FILES_ONLY
parameter?Here is my use case. I've got a symfony project with ~5k php files in src folder. I want to use
MessageSubscriberInterfaceToAttributeRector
rector in order to add an attribute instead of the deprecated interface.If I just go without any parameters, rector would add a with the full namespace path in the attribute, e.g.
I don't want this to happen so I'm using:
Now it works OK, but besides the intended change, it alters hundreds of files, just to change
\Namespace\Class
calls to an alias. It might be a good idea, but not in a legacy project, when I must only change those things I'm sure about and do not touch hundreds of files, which time has not yet come.The text was updated successfully, but these errors were encountered: