Skip to content

Commit

Permalink
Fix broken boolean types on IniFileLoader (#1355) (#1356)
Browse files Browse the repository at this point in the history
  • Loading branch information
gboddin authored and marcj committed May 26, 2017
1 parent 9e4039d commit 1ab6786
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Propel/Common/Config/Loader/IniFileLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
class IniFileLoader extends FileLoader
{

/**
* Separator for nesting levels of configuration data identifiers.
*
Expand Down Expand Up @@ -58,7 +59,7 @@ public function supports($resource, $type = null)
*/
public function load($file, $type = null)
{
$ini = parse_ini_file($this->getPath($file), true);
$ini = parse_ini_file($this->getPath($file), true, INI_SCANNER_RAW);

if (false === $ini) {
throw new InvalidArgumentException("The configuration file '$file' has invalid content.");
Expand All @@ -71,8 +72,8 @@ public function load($file, $type = null)
}

/**
* Parse data from the configuration array, to transform nested sections into associative arrays.
*
* Parse data from the configuration array, to transform nested sections into associative arrays
* and to fix int/float/bool typing
* @param array $data
* @return array
*/
Expand Down Expand Up @@ -163,6 +164,12 @@ private function parseKey($key, $value, array &$config)
}

$this->parseKey($pieces[1], $value, $config[$pieces[0]]);
} else if (is_string($value) && in_array(strtolower($value), array("true", "false"))) {
$config[$key] = (strtolower($value) === "true");
} else if ($value === (string)(int) $value) {
$config[$key] = (int) $value;
} else if ($value === (string)(float) $value) {
$config[$key] = (float) $value;
} else {
$config[$key] = $value;
}
Expand Down

0 comments on commit 1ab6786

Please sign in to comment.