Skip to content
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

[Config] Add merging of rules configuration, call configure() just once #4838

Merged
merged 2 commits into from Aug 23, 2023

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Aug 23, 2023

@TomasVotruba TomasVotruba changed the title [Config] Add merging of rules configuration, add just once [Config] Add merging of rules configuration, call configure() just once Aug 23, 2023
Comment on lines +180 to 185
if ($isBound) {
return;
}

$this->singleton($rectorClass);
$this->tagRectorService($rectorClass);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without this check, the same Rector rule would be registered twice. That could lead to unexpected changes and waste of resources.

): void {
$ruleConfiguration = $this->ruleConfigurations[$rectorClass];
$configurableRector->configure($ruleConfiguration);
});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The configure() is now called exactly once with the full configuration.

We might check for the configuration override and have custom property to add this after resolving too. In case of non-configurable rules, but it might be too defensive. Let's see how it performs :)

@TomasVotruba
Copy link
Member Author

Thanks for the solution @samsonasik 👍

@TomasVotruba TomasVotruba merged commit ce87fc2 into main Aug 23, 2023
39 checks passed
@TomasVotruba TomasVotruba deleted the tv-fix-merge-configures branch August 23, 2023 13:17
@samsonasik
Copy link
Member

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants