Skip to content

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

Merged
TomasVotruba merged 2 commits intomainfrom
tv-fix-merge-configures
Aug 23, 2023
Merged

[Config] Add merging of rules configuration, call configure() just once#4838
TomasVotruba merged 2 commits intomainfrom
tv-fix-merge-configures

Conversation

@TomasVotruba
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

Thanks for the solution @samsonasik 👍

@samsonasik
Copy link
Copy Markdown
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

Development

Successfully merging this pull request may close these issues.

AnnotationToAttributeRector misbehaves since v0.18.0

2 participants