-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[DependencyInjection] Allow calling custom processors directly on EnvConfigurator #40779
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 magic __call method to EnvConfigurator to allow calling custom processors as methods instead of using the custom method.
*/ | ||
public function __call(string $name, array $arguments): self | ||
{ | ||
$processor = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $name)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could add a dependency on the string component instead here but not sure if it is worth it.
{ | ||
$processor = strtolower(preg_replace(['/([A-Z]+)([A-Z][a-z])/', '/([a-z\d])([A-Z])/'], '\1_\2', $name)); | ||
|
||
$this->custom($processor, ...$arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's remove custom() instead, don't you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to use custom
over magic methods.
Thank you @jvasseur. |
This is a proposition of addition to the feature added by #40682 to allow calling custom processors in the same way we call builtin ones. This is not perfect since it doesn't allow auto-completion for these custom methods but I think this provides a cleaner API for custom processors.