bug #26895 [Config] Fixes the valid placeholder types for variable node (romain-pierre)
This PR was merged into the 4.1-dev branch.
Discussion
----------
[Config] Fixes the valid placeholder types for variable node
| Q | A
| ------------- | ---
| Branch? | master
| Bug fix? | yes
| New feature? | no <!-- don't forget to update src/**/CHANGELOG.md files -->
| BC breaks? | no <!-- see https://symfony.com/bc -->
| Deprecations? | no <!-- don't forget to update UPGRADE-*.md and src/**/CHANGELOG.md files -->
| Tests pass? | we will see... <!-- please add some, will be required by reviewers -->
| Fixed tickets | #26894
| License | MIT
This is a proposition, still in discussion.
<!--
Write a short README entry for your feature/bugfix here (replace this comment block.)
This will help people understand your PR and can be used as a start of the Doc PR.
Additionally:
- Bug fixes must be submitted against the lowest branch where they apply
(lowest branches are regularly merged to upper ones so they get the fixes too).
- Features and deprecations must be submitted against the master branch.
-->
Commits
-------
9fbdcdbeb9
Fixes the valid placeholder types for variable node
This commit is contained in:
commit
d2f8df8054
@ -539,7 +539,7 @@ abstract class BaseNode implements NodeInterface
|
|||||||
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
|
||||||
$validTypes = $this->getValidPlaceholderTypes();
|
$validTypes = $this->getValidPlaceholderTypes();
|
||||||
|
|
||||||
if (array_diff($knownTypes, $validTypes)) {
|
if ($validTypes && array_diff($knownTypes, $validTypes)) {
|
||||||
$e = new InvalidTypeException(sprintf(
|
$e = new InvalidTypeException(sprintf(
|
||||||
'Invalid type for path "%s". Expected %s, but got %s.',
|
'Invalid type for path "%s". Expected %s, but got %s.',
|
||||||
$this->getPath(),
|
$this->getPath(),
|
||||||
|
@ -209,6 +209,19 @@ class ValidateEnvPlaceholdersPassTest extends TestCase
|
|||||||
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
|
$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
|
private function doProcess(ContainerBuilder $container): void
|
||||||
{
|
{
|
||||||
(new MergeExtensionConfigurationPass())->process($container);
|
(new MergeExtensionConfigurationPass())->process($container);
|
||||||
@ -247,6 +260,7 @@ class EnvConfiguration implements ConfigurationInterface
|
|||||||
->end()
|
->end()
|
||||||
->arrayNode('simple_array_node')->end()
|
->arrayNode('simple_array_node')->end()
|
||||||
->enumNode('enum_node')->values(array('a', 'b'))->end()
|
->enumNode('enum_node')->values(array('a', 'b'))->end()
|
||||||
|
->variableNode('variable_node')->end()
|
||||||
->end();
|
->end();
|
||||||
|
|
||||||
return $treeBuilder;
|
return $treeBuilder;
|
||||||
|
Reference in New Issue
Block a user