phpro / grumphp

A PHP code-quality tool
MIT License
4.15k stars 431 forks source link

Imported config gets overwritten not customized #480

Closed thomscode closed 6 years ago

thomscode commented 6 years ago
Q A
Version 0.14.0
Bug? yes
New feature? no
Question? no
Documentation? no
Related tickets no

My company develops and hosts several Drupal sites, which we are starting to manage with Composer. To help with checking files, I setup a base GrumPHP configuration to share across projects and am using the imports key to import that into the project so I can continue to customize the settings as projects have need to do so. I set this up per the "convention" instructions in the Docs

The shared configuration contains task settings. If I try to overwrite the settings for any given task, GrumPHP overwrites the entire tasks key (possibly parameters too).

My shared configuration

# grumphp.yml
parameters:
  tasks:
    composer: ~
    file_size: ~
    phpcs:
      standard: vendor/drupal/coder/coder_sniffer/Drupal
      triggered_by: ["php", "module", "profile", "theme", "inc"]
    phplint:
      triggered_by: ["php", "module", "profile", "theme", "inc"]
    phpmd:
      triggered_by: ["php", "module", "profile", "theme", "inc"]
    phpparser:
      kind: php5
      triggered_by: ["php", "module", "profile", "theme", "inc"]
    phpversion:
      project: "5.6"
    securitychecker: ~

My configuration

# grumphp.yml
imports:
  - resource: my/other/shared/grumphp.yml
parameters:
  tasks:
    jsonlint: ~
    yamllint:~

Steps to reproduce:

Expected: I would have expected that the two configurations would have been merged and not that the second would overwrite the first.

veewee commented 6 years ago

Hi @thomscode,

Thanks for reporting. We are using the default Syfmony container as a configuration tool for this project. This is just how the Symfony container merges config. There isn't really anything we can do about this.

You might want to create a grumphp extension instead which gives you full control over the container. More info about extensions: https://github.com/phpro/grumphp/blob/master/doc/extensions.md

The format as described in the conventions document is assuming that you do not add new tasks in sub projects but in the convention file instead.