Skip to content

Env variables don't get expanded in task definitions #1146

@indykoning

Description

@indykoning
Q A
Version GrumPHP 2.6.0
Bug? yes
New feature? no
Question? no
Documentation? yes

Following the docs on using environment variables and parameters doesn't actually function as expected.
The example seems to work, however setting the variable to false still has the config enabled.

i've debugged it by using it in a task and dumping the task definition in the code. Which results in:

GrumPHP\Task\Config\Metadata^ {#659
  -metadata: array:5 [
    "blocking" => true
    "task" => ""
    "label" => ""
    "priority" => 0
    "enabled" => "env_19eeff9b12d8f08c_bool_GRUM_COMPOSER_NORMALIZE_ENABLED_b9f45633a4808b98cb74867bcd84c333"
  ]
}

instead of the expected bool value, it is a string identifying the variable to be resolved.
This feels similar to symfony/symfony#45868

My configuration

# grumphp.yml
parameters:
    env(GRUM_COMPOSER_NORMALIZE_ENABLED): 'false'
    env(GRUM_COMPOSER_NORMALIZE_VERBOSE): 'false'
    
grumphp:
    tasks:
        composer_normalize:
            metadata:
                enabled: '%env(bool:GRUM_COMPOSER_NORMALIZE_ENABLED)%'
            indent_size: 4
            indent_style: "space"
            no_update_lock: false
            verbose: '%env(bool:GRUM_COMPOSER_NORMALIZE_VERBOSE)%'

Steps to reproduce:

# Generate empty folder
mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Run GrumPHP:
git add -A && git commit -m"Test"
# or
./vendor/bin/grumphp run

Result:

Composer normalize is still excecuted instead of not excecuting at all

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions