phpro / grumphp

A PHP code-quality tool
MIT License
4.12k stars 430 forks source link

Using variable to define run_on path? #974

Closed mikkmiggur closed 2 years ago

mikkmiggur commented 2 years ago
Q A
Version GrumPHP 1.5.0
Bug? no
New feature? no
Question? yes
Documentation? no
Related tickets

My configuration

grumphp:
  additional_info: "'web/modules/custom', 'web/themes/custom'"
  stop_on_failure: false
  process_timeout: 300
  ascii:
    failed: ~
    succeeded: ~
  tasks:
    php_compatibility:
      run_on: [${additional_info}]
      testVersion: '7.4'
    check_file_permissions:
      run_on: [${additional_info}]
    php_check_syntax:
      run_on: [${additional_info}]
    phpcs:
      run_on: [${additional_info}]
   ....

I was looking away to get run_on as a variable in the tasks. It's easier to maintain and use if this value is defined only once. But the list of variables that can be used under the grumphp is quite limited. PHP Fatal error: Uncaught Symfony\Component\Config\Definition\Exception\InvalidConfigurationException: Unrecognized option "run_on" under "grumphp". Available options are "additional_info", "ascii", "environment", "extensions", "fixer", "git_hook_variables", "hide_circumvention_tip", "hooks_dir", "hooks_preset", "ignore_unstaged_changes", "parallel", "process_timeout", "stop_on_failure", "tasks", "testsuites". in /app/vendor/symfony/config/Definition/ArrayNode.php:315

My question here is, is it fine to use additional_info for that?

veewee commented 2 years ago

The config file is a symfony container config file. This means that you can use the parameters section for this and use these parameters just like you would in symfonys container.

https://symfony.com/doc/current/configuration.html#configuration-parameters