Fixes the valid placeholder types for variable node
This commit is contained in:
parent
9a999553a5
commit
9fbdcdbeb9
@ -539,7 +539,7 @@ abstract class BaseNode implements NodeInterface
|
||||
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
||||
$validTypes = $this->getValidPlaceholderTypes();
|
||||
|
||||
if (array_diff($knownTypes, $validTypes)) {
|
||||
if ($validTypes && array_diff($knownTypes, $validTypes)) {
|
||||
$e = new InvalidTypeException(sprintf(
|
||||
'Invalid type for path "%s". Expected %s, but got %s.',
|
||||
$this->getPath(),
|
||||
|
@ -209,6 +209,19 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
||||
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
||||
}
|
||||
|
||||
public function testEnvWithVariableNode(): void
|
||||
{
|
||||
$container = new ContainerBuilder();
|
||||
$container->registerExtension($ext = new EnvExtension());
|
||||
$container->prependExtensionConfig('env_extension', $expected = array(
|
||||
'variable_node' => '%env(SOME)%',
|
||||
));
|
||||
|
||||
$this->doProcess($container);
|
||||
|
||||
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
||||
}
|
||||
|
||||
private function doProcess(ContainerBuilder $container): void
|
||||
{
|
||||
(new MergeExtensionConfigurationPass())->process($container);
|
||||
@ -247,6 +260,7 @@ class EnvConfiguration implements ConfigurationInterface
|
||||
->end()
|
||||
->arrayNode('simple_array_node')->end()
|
||||
->enumNode('enum_node')->values(array('a', 'b'))->end()
|
||||
->variableNode('variable_node')->end()
|
||||
->end();
|
||||
|
||||
return $treeBuilder;
|
||||
|
Reference in New Issue
Block a user