Open stevenart opened 3 years ago
I found the way to fix the behaviour of 0.6.2 to match 0.5. In the function returnKeyValuePair
, I replaced the ": " string by simply ":". It now explodes on ":", not ": ".
private function returnKeyValuePair ($line) {
$array = array();
$key = '';
if (strpos ($line, ':')) {
// It's a key/value pair most likely
// If the key is in double quotes pull it out
if (($line[0] == '"' || $line[0] == "'") && preg_match('/^(["\'](.*)["\'](\s)*:)/',$line,$matches)) {
$value = trim(str_replace($matches[1],'',$line));
$key = $matches[2];
} else {
// Do some guesswork as to the key and the value
$explode = explode(':', $line);
$key = trim(array_shift($explode));
$value = trim(implode(':', $explode));
$this->checkKeysInValue($value);
}
// Set the type of the value. Int, string, etc
$value = $this->_toType($value);
if ($key === '0') $key = '__!YAMLZero';
$array[$key] = $value;
} else {
$array = array ($line);
}
return $array;
}
If y have the following code in my YAML file :
primary: [section, key]
(the character between "primary:" and "[sec..." is a tab [\t]) then the array is not parsed and returned as string :Array ( [0] => name: i18n [1] => table: _i18n_site [2] => primary: [section, key]
But if i add a space before the tab, it works :
primary: [section, key]
(two characters between "primary:" and "[sec..." = a space followed by a tab [\t]) then it works :Array ( [0] => name: i18n [1] => table: _i18n_site [primary] => Array ( [0] => section [1] => key )
Both worked with spyc 0.5 but now with 0.6.2, it's not. Is there something I'm missing?