Skip to content

Commit 93f50bf

Browse files
committed
Merge branch '3.2'
* 3.2: (24 commits) [Filesystem] Remove extra argv in dumpFile() tests [DI] minor FileLoaders tests update [FrameworkBundle] Add framework.cache.prefix_seed for predictible cache key prefixes [SecurityBundle] Remove FirewallContext mandatory FirewallConfig argument deprecation [HttpKernel] Revert BC breaking change of Request::isMethodSafe() [DI] Allow null as default env value [WebProfilerBundle] Fix deprecated uses of profiler_dump [SecurityBundle] Fix FirewallConfig nullable arguments [FrameworkBundle] Avoid warming up the validator cache for non-existent classes [DOMCrawler] Bug fixed [FrameworkBundle] Mark cache.default_*_provider services private [Process] Do feat test before enabling TTY mode bumped Symfony version to 3.1.8 updated VERSION for 3.1.7 updated CHANGELOG for 3.1.7 bumped Symfony version to 2.8.15 updated VERSION for 2.8.14 updated CHANGELOG for 2.8.14 bumped Symfony version to 2.7.22 updated VERSION for 2.7.21 ...
2 parents 6b46d7f + a3c1c3b commit 93f50bf

File tree

4 files changed

+31
-9
lines changed

4 files changed

+31
-9
lines changed

ParameterBag/EnvPlaceholderParameterBag.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ public function get($name)
4141
if ($this->has($name)) {
4242
$defaultValue = parent::get($name);
4343

44-
if (!is_scalar($defaultValue)) {
45-
throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar, but "%s" given to "%s".', gettype($defaultValue), $name));
44+
if (null !== $defaultValue && !is_scalar($defaultValue)) {
45+
throw new RuntimeException(sprintf('The default value of an env() parameter must be scalar or null, but "%s" given to "%s".', gettype($defaultValue), $name));
4646
}
4747
}
4848

@@ -96,8 +96,8 @@ public function resolve()
9696
}
9797
if (is_numeric($default = $this->parameters[$name])) {
9898
$this->parameters[$name] = (string) $default;
99-
} elseif (null !== $default && !is_string($default)) {
100-
throw new RuntimeException(sprintf('The default value of env parameter "%s" must be string or null, %s given.', $env, gettype($default)));
99+
} elseif (null !== $default && !is_scalar($default)) {
100+
throw new RuntimeException(sprintf('The default value of env parameter "%s" must be scalar or null, %s given.', $env, gettype($default)));
101101
}
102102
}
103103
}

Tests/Loader/XmlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ public function testLoadImports()
131131
{
132132
$container = new ContainerBuilder();
133133
$resolver = new LoaderResolver(array(
134-
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
135-
new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
134+
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')),
135+
new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yml')),
136136
$loader = new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
137137
));
138138
$loader->setResolver($resolver);

Tests/Loader/YamlFileLoaderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ public function testLoadImports()
104104
{
105105
$container = new ContainerBuilder();
106106
$resolver = new LoaderResolver(array(
107-
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
108-
new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
107+
new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini')),
108+
new XmlFileLoader($container, new FileLocator(self::$fixturesPath.'/xml')),
109109
new PhpFileLoader($container, new FileLocator(self::$fixturesPath.'/php')),
110110
$loader = new YamlFileLoader($container, new FileLocator(self::$fixturesPath.'/yaml')),
111111
));

Tests/ParameterBag/EnvPlaceholderParameterBagTest.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public function testResolveEnvAllowsNull()
130130

131131
/**
132132
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
133-
* @expectedExceptionMessage The default value of env parameter "ARRAY_VAR" must be string or null, array given.
133+
* @expectedExceptionMessage The default value of env parameter "ARRAY_VAR" must be scalar or null, array given.
134134
*/
135135
public function testResolveThrowsOnBadDefaultValue()
136136
{
@@ -139,4 +139,26 @@ public function testResolveThrowsOnBadDefaultValue()
139139
$bag->set('env(Array_Var)', array());
140140
$bag->resolve();
141141
}
142+
143+
public function testGetEnvAllowsNull()
144+
{
145+
$bag = new EnvPlaceholderParameterBag();
146+
$bag->set('env(NULL_VAR)', null);
147+
$bag->get('env(NULL_VAR)');
148+
$bag->resolve();
149+
150+
$this->assertNull($bag->all()['env(null_var)']);
151+
}
152+
153+
/**
154+
* @expectedException \Symfony\Component\DependencyInjection\Exception\RuntimeException
155+
* @expectedExceptionMessage The default value of an env() parameter must be scalar or null, but "array" given to "env(ARRAY_VAR)".
156+
*/
157+
public function testGetThrowsOnBadDefaultValue()
158+
{
159+
$bag = new EnvPlaceholderParameterBag();
160+
$bag->set('env(ARRAY_VAR)', array());
161+
$bag->get('env(ARRAY_VAR)');
162+
$bag->resolve();
163+
}
142164
}

0 commit comments

Comments
 (0)