8000 bug #26895 [Config] Fixes the valid placeholder types for variable no… · symfony/symfony@d2f8df8 · GitHub
[go: up one dir, main page]

Skip to content

Commit d2f8df8

Browse files
committed
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 ------- 9fbdcdb Fixes the valid placeholder types for variable node
2 parents 7e4de96 + 9fbdcdb commit d2f8df8

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Symfony/Component/Config/Definition/BaseNode.php

Lines changed: 1 addition & 1 deletion
8000
Original file line numberDiff line numberDiff line change
@@ -539,7 +539,7 @@ private function doValidateType($value): void
539539
$knownTypes = array_keys(self::$placeholders[$this->handlingPlaceholder]);
540540
$validTypes = $this->getValidPlaceholderTypes();
541541

542-
if (array_diff($knownTypes, $validTypes)) {
542+
if ($validTypes && array_diff($knownTypes, $validTypes)) {
543543
$e = new InvalidTypeException(sprintf(
544544
'Invalid type for path "%s". Expected %s, but got %s.',
545545
$this->getPath(),

src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@ public function testEmptyEnvWhichCannotBeEmptyForScalarNode(): void
209209
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
210210
}
211211

212+
public function testEnvWithVariableNode(): void
213+
{
214+
$container = new ContainerBuilder();
215+
$container->registerExtension($ext = new EnvExtension());
216+
$container->prependExtensionConfig('env_extension', $expected = array(
217+
'variable_node' => '%env(SOME)%',
218+
));
219+
220+
$this->doProcess($container);
221+
222+
$this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig()));
223+
}
224+
212225
private function doProcess(ContainerBuilder $container): void
213226
{
214227
(new MergeExtensionConfigurationPass())->process($container);
@@ -247,6 +260,7 @@ public function getConfigTreeBuilder()
247260
->end()
248261
->arrayNode('simple_array_node')->end()
249262
->enumNode('enum_node')->values(array('a', 'b'))->end()
263+
->variableNode('variable_node')->end()
250264
->end();
251265

252266
return $treeBuilder;

0 commit comments

Comments
 (0)
0