-
-
Notifications
You must be signed in to change notification settings - Fork 430
Add withImport() method to RectorConfigBuilder #7837
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
Conversation
- Add withImport() method to import configuration files - Import files are processed in __invoke() before other configuration - Add unit tests with single, multiple, and nested import scenarios - Fixture configs use RectorConfigBuilder pattern
|
There is already ->withSets([
__DIR__ . '/my/rector.php',
]) |
|
@samsonasik yes, but the use case would be, for example, having different configurations for local and CI, with a base common configuration. And we want to import whole configuration, not just sets or rules |
|
I believe all these test failures are unrelated to my PR |
|
the rector-src/src/Configuration/RectorConfigBuilder.php Lines 219 to 268 in f1c5104
Have a 2 way to import sets will make buggy code and possible future unwanted reported issue :) |
|
@samsonasik but this is not just about sets, this is what I am trying to say. To give you one example:
So I would have three config files: Both rector.php and rector_ci.php import rector_base.php This cannot be done with the existing code unless I repeat the set of rules both in rector.php and rector_ci.php This is just one example but I can think of many more where this would be useful. I ask you to please reconsider and re-open the PR as I think it is a valid concern |
|
@samsonasik also, the capability to import other config files already exists through the |
|
The The |
|
@carlos-granados Indeed, we use "sets" as a synonym to "imports". It was leftover from Symfony naming, a DI container we used in the past. I prefer to stick with one naming here as sets are major killer feature of Rector. |
|
@TomasVotruba @samsonasik thanks for the explanation, I did not realise that the withSets function actually called import internally. But I hope that you realise that, even if it is the historical usage in Rector, it is not obvious, natural or evident that you need to call |
|
Reading the #7837 (comment), instead of creating multiple configs, which is necessary if there is format like XML, YML etc., you can make use of PHP itself in single config: $processCount = ...;
// ...
->withParallel($processCount);It's also more readable than config juggling to change sole value. I've seen other devs using same logic to configure temp directory based on env 👍 |
The
RectorConfigclass has a function,import()that allow you to import another configuration file but this was never exposed in theRectorConfigBuilderclass. This PR adds awithImport()function to the builder class that allows you to import other configuration files while using it