Skip to content

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

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

GuillaumeOnepilot
Copy link

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)

@taylorotwell taylorotwell marked this pull request as draft June 9, 2025 14:36
throw new \LogicException('Configuration cannot extend from more than 1 config');
}

$baseConfig = array_merge(
Copy link
Member

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
        },
        ...

Copy link
Author

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

@GuillaumeOnepilot
Copy link
Author

Added another test that check the correct throw of the exception to avoid config recursions

@GuillaumeOnepilot GuillaumeOnepilot marked this pull request as ready for review June 20, 2025 07:18
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.

3 participants