Revert "merged branch stealth35/ini_bool (PR #2235)"

This reverts commit 363057b181, reversing
changes made to 545cd4cd63.
This commit is contained in:
Fabien Potencier 2011-09-25 11:33:22 +02:00
parent fa13469bba
commit 49c585ebd2
3 changed files with 1 additions and 15 deletions

View File

@ -35,18 +35,13 @@ class IniFileLoader extends FileLoader
$this->container->addResource(new FileResource($path));
$result = parse_ini_file($path, true, INI_SCANNER_RAW);
$result = parse_ini_file($path, true);
if (false === $result || array() === $result) {
throw new \InvalidArgumentException(sprintf('The "%s" file is not valid.', $file));
}
if (isset($result['parameters']) && is_array($result['parameters'])) {
foreach ($result['parameters'] as $key => $value) {
switch (strtolower($value)) {
case 'true' : $value = true ; break;
case 'false': $value = false; break;
case 'null' : $value = null ; break;
}
$this->container->setParameter($key, $value);
}
}

View File

@ -1,4 +0,0 @@
[parameters]
foo = true
bar = False
boo = NULL

View File

@ -35,11 +35,6 @@ class IniFileLoaderTest extends \PHPUnit_Framework_TestCase
$loader->load('parameters.ini');
$this->assertEquals(array('foo' => 'bar', 'bar' => '%foo%'), $container->getParameterBag()->all(), '->load() takes a single file name as its first argument');
$container = new ContainerBuilder();
$loader = new IniFileLoader($container, new FileLocator(self::$fixturesPath.'/ini'));
$loader->load('boolean.ini');
$this->assertEquals(array('foo' => true, 'bar' => false, 'boo' => null), $container->getParameterBag()->all());
try {
$loader->load('foo.ini');
$this->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');