File tree Expand file tree Collapse file tree 2 files changed +10
-1
lines changed
src/Symfony/Component/DependencyInjection Expand file tree Collapse file tree 2 files changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ public function process(ContainerBuilder $container)
4848 foreach ($ resolvingBag ->getEnvPlaceholders () + $ resolvingBag ->getUnusedEnvPlaceholders () as $ env => $ placeholders ) {
4949 $ values = array ();
5050 if (false === $ i = strpos ($ env , ': ' )) {
51- $ default = $ defaultBag ->has ("env( $ env) " ) ? $ defaultBag ->get ("env( $ env) " ) : null ;
51+ $ default = $ defaultBag ->has ("env( $ env) " ) ? $ defaultBag ->get ("env( $ env) " ) : self :: $ typeFixtures [ ' string ' ] ;
5252 $ defaultType = null !== $ default ? self ::getType ($ default ) : 'string ' ;
5353 $ values [$ defaultType ] = $ default ;
5454 } else {
Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ public function testDefaultEnvWithoutPrefixIsValidatedInConfig()
4848 $ container ->registerExtension ($ ext = new EnvExtension ());
4949 $ container ->prependExtensionConfig ('env_extension ' , $ expected = array (
5050 'float_node ' => '%env(FLOATISH)% ' ,
51+ 'string_node ' => '%env(UNDEFINED)% ' ,
5152 ));
5253
5354 $ this ->doProcess ($ container );
@@ -311,6 +312,14 @@ public function getConfigTreeBuilder()
311312 ->arrayNode ('simple_array_node ' )->end ()
312313 ->enumNode ('enum_node ' )->values (array ('a ' , 'b ' ))->end ()
313314 ->variableNode ('variable_node ' )->end ()
315+ ->scalarNode ('string_node ' )
316+ ->validate ()
317+ ->ifTrue (function ($ value ) {
318+ return !\is_string ($ value );
319+ })
320+ ->thenInvalid ('%s is not a string ' )
321+ ->end ()
322+ ->end ()
314323 ->end ();
315324
316325 return $ treeBuilder ;
You can’t perform that action at this time.
0 commit comments