From ec27d7486d2b764a9ed6bcadbd10fd5ce98c0dcb Mon Sep 17 00:00:00 2001 From: Roland Franssen Date: Wed, 29 May 2019 09:55:56 +0200 Subject: [PATCH] [Config] Removed env var support with cannotBeEmpty() --- .../Component/Config/Definition/VariableNode.php | 15 +++++++-------- .../Compiler/ValidateEnvPlaceholdersPassTest.php | 13 +++++++------ 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/Symfony/Component/Config/Definition/VariableNode.php b/src/Symfony/Component/Config/Definition/VariableNode.php index 0d722c6bd28a8..0bcb28f233b17 100644 --- a/src/Symfony/Component/Config/Definition/VariableNode.php +++ b/src/Symfony/Component/Config/Definition/VariableNode.php @@ -84,14 +84,13 @@ protected function finalizeValue($value) // deny environment variables only when using custom validators // this avoids ever passing an empty value to final validation closures if (!$this->allowEmptyValue && $this->isHandlingPlaceholder() && $this->finalValidationClosures) { - @trigger_error(sprintf('Setting path "%s" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead.', $this->getPath()), E_USER_DEPRECATED); -// $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath(), json_encode($value))); -// if ($hint = $this->getInfo()) { -// $e->addHint($hint); -// } -// $e->setPath($this->getPath()); -// -// throw $e; + $e = new InvalidConfigurationException(sprintf('The path "%s" cannot contain an environment variable when empty values are not allowed by definition and are validated.', $this->getPath(), json_encode($value))); + if ($hint = $this->getInfo()) { + $e->addHint($hint); + } + $e->setPath($this->getPath()); + + throw $e; } if (!$this->allowEmptyValue && $this->isValueEmpty($value)) { diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php index 84d6d8db82835..bfc4b2c56e7d8 100644 --- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php +++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ValidateEnvPlaceholdersPassTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\DependencyInjection\Tests\Compiler; use PHPUnit\Framework\TestCase; +use Symfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface; use Symfony\Component\Config\Definition\Builder\TreeBuilder; use Symfony\Component\Config\Definition\ConfigurationInterface; use Symfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass; @@ -229,13 +230,15 @@ public function testEmptyEnvWhichCannotBeEmptyForScalarNode(): void } /** - * NOT LEGACY (test exception in 5.0). - * - * @group legacy - * @expectedDeprecation Setting path "env_extension.scalar_node_not_empty_validated" to an environment variable is deprecated since Symfony 4.3. Remove "cannotBeEmpty()", "validate()" or include a prefix/suffix value instead. + * @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException + * @expectedExceptionMessage The path "env_extension.scalar_node_not_empty_validated" cannot contain an environment variable when empty values are not allowed by definition and are validated. */ public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation(): void { + if (!method_exists(ParentNodeDefinitionInterface::class, 'getChildNodeDefinitions')) { + $this->markTestSkipped('symfony/config >=5.0 is required.'); + } + $container = new ContainerBuilder(); $container->registerExtension($ext = new EnvExtension()); $container->prependExtensionConfig('env_extension', $expected = [ @@ -243,8 +246,6 @@ public function testEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation(): voi ]); $this->doProcess($container); - - $this->assertSame($expected, $container->resolveEnvPlaceholders($ext->getConfig())); } public function testPartialEnvWhichCannotBeEmptyForScalarNode(): void pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy