bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

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

Open roman-vohnik opened this issue 5 months ago • 0 comments

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 % ?

roman-vohnik avatar Aug 14 '25 10:08 roman-vohnik