Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commita2f2769

Browse files
minor#31678 [Config] Removed env var support with cannotBeEmpty() (ro0NL)
This PR was merged into the 5.0-dev branch.Discussion----------[Config] Removed env var support with cannotBeEmpty()| Q | A| ------------- | ---| Branch? | master| Bug fix? | no| New feature? | no| BC breaks? | no <!-- seehttps://symfony.com/bc -->| Deprecations? | no| Tests pass? | yes <!-- please add some, will be required by reviewers -->| Fixed tickets | #... <!-- #-prefixed issue number(s), if any -->| License | MIT| Doc PR | symfony/symfony-docs#... <!-- required for new features -->See#28858Commits-------ec27d74 [Config] Removed env var support with cannotBeEmpty()
2 parents8e84328 +ec27d74 commita2f2769

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

‎src/Symfony/Component/Config/Definition/VariableNode.php‎

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,13 @@ protected function finalizeValue($value)
8484
// deny environment variables only when using custom validators
8585
// this avoids ever passing an empty value to final validation closures
8686
if (!$this->allowEmptyValue &&$this->isHandlingPlaceholder() &&$this->finalValidationClosures) {
87-
@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);
88-
// $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)));
89-
// if ($hint = $this->getInfo()) {
90-
// $e->addHint($hint);
91-
// }
92-
// $e->setPath($this->getPath());
93-
//
94-
// throw $e;
87+
$e =newInvalidConfigurationException(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)));
88+
if ($hint =$this->getInfo()) {
89+
$e->addHint($hint);
90+
}
91+
$e->setPath($this->getPath());
92+
93+
throw$e;
9594
}
9695

9796
if (!$this->allowEmptyValue &&$this->isValueEmpty($value)) {

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
namespaceSymfony\Component\DependencyInjection\Tests\Compiler;
1313

1414
usePHPUnit\Framework\TestCase;
15+
useSymfony\Component\Config\Definition\Builder\ParentNodeDefinitionInterface;
1516
useSymfony\Component\Config\Definition\Builder\TreeBuilder;
1617
useSymfony\Component\Config\Definition\ConfigurationInterface;
1718
useSymfony\Component\DependencyInjection\Compiler\MergeExtensionConfigurationPass;
@@ -229,22 +230,22 @@ public function testEmptyEnvWhichCannotBeEmptyForScalarNode(): void
229230
}
230231

231232
/**
232-
* NOT LEGACY (test exception in 5.0).
233-
*
234-
* @group legacy
235-
* @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.
233+
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
234+
* @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.
236235
*/
237236
publicfunctiontestEmptyEnvWhichCannotBeEmptyForScalarNodeWithValidation():void
238237
{
238+
if (!method_exists(ParentNodeDefinitionInterface::class,'getChildNodeDefinitions')) {
239+
$this->markTestSkipped('symfony/config >=5.0 is required.');
240+
}
241+
239242
$container =newContainerBuilder();
240243
$container->registerExtension($ext =newEnvExtension());
241244
$container->prependExtensionConfig('env_extension',$expected = [
242245
'scalar_node_not_empty_validated' =>'%env(SOME)%',
243246
]);
244247

245248
$this->doProcess($container);
246-
247-
$this->assertSame($expected,$container->resolveEnvPlaceholders($ext->getConfig()));
248249
}
249250

250251
publicfunctiontestPartialEnvWhichCannotBeEmptyForScalarNode():void

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp