-
Notifications
You must be signed in to change notification settings - Fork 153
Feature allow configuration extension from a different base file #373
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
base: main
Are you sure you want to change the base?
Feature allow configuration extension from a different base file #373
Conversation
throw new \LogicException('Configuration cannot extend from more than 1 config'); | ||
} | ||
|
||
$baseConfig = array_merge( |
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.
Maybe this should be array_merge_recursive? What do you think?
Also, can you add more tests that expand on this—to determine exactly which configuration will be used, especially when dealing with nested JSON files like this:
{
"preset": "laravel",
"rules": {
"array_push": true,
"backtick_to_shell_exec": true,
"date_time_immutable": true,
"declare_strict_types": true,
"lowercase_keywords": true,
"lowercase_static_reference": true,
"final_class": true,
"final_internal_class": true,
"final_public_method_for_abstract_class": true,
"fully_qualified_strict_types": true,
"global_namespace_import": {
"import_classes": true,
"import_constants": true,
"import_functions": true
},
...
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 resorted to use array_replace_recursive
, array_merge_recursive
merge non array keys into a new array, which is not expected behavior.
I've added tests covering the nested JSON use case
Added another test that check the correct throw of the exception to avoid config recursions |
I have a use case where my company uses a global pint config, this work fine if the config doesn't need to change per project, but if we need to have project specific configuration, it becomes impossible to have them isolated.
It partially solves #174
I purposefully chose to only allow 1 extend to avoid recursion issues (though it could be fixed through a fixed set of extent)