Skip to content

Array replacing operator ! in neon config does not work when the array is referenced static parameter #74

@roman-vohnik

Description

@roman-vohnik

Version: 3.2.4

Bug Description

Array replacing operator ! in neon config does not work when the array is referenced static parameter.

My use-case is that some of my ENV variables are json encoded arrays (list of servers for example) and I'm adding them as static parameters because some extensions doesn't like ::getenv(). Regular definition works, but I need to be sure the values are not merged. In this case I'm getting following error, because in this stage NeonAdapter::process gets not yet replaced string value %env.ARRAY%

Steps To Reproduce

$configurator = new Configurator();
$configurator->addStaticParameters([
    'env' => [
        'ARRAY' => ['foo', 'bar'],
    ],
]);
parameters:
  foo: %env.ARRAY%   # <-- it works
  bar!: %env.ARRAY%  # <-- it doesn't work

throws Nette\DI\InvalidConfigurationException Replacing operator is available only for arrays, item 'bar!' is not array (used in '/.../config.local.neon')

Expected Behavior

bar with operator ! preventing array merge (replacing operator) should work.

Possible Solution

Maybe introduce here simple condition to not check if value is array when it is starting with % ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions