private static function Inline::parseSequence in Zircon Profile 8.0
Same name and namespace in other branches
- 8 vendor/symfony/yaml/Inline.php \Symfony\Component\Yaml\Inline::parseSequence()
Parses a sequence to a YAML string.
Parameters
string $sequence:
int &$i:
array $references:
Return value
string A YAML string
Throws
ParseException When malformed inline YAML string is parsed
2 calls to Inline::parseSequence()
- Inline::parse in vendor/
symfony/ yaml/ Inline.php - Converts a YAML string to a PHP array.
- Inline::parseMapping in vendor/
symfony/ yaml/ Inline.php - Parses a mapping to a YAML string.
File
- vendor/
symfony/ yaml/ Inline.php, line 286
Class
- Inline
- Inline implements a YAML parser/dumper for the YAML inline syntax.
Namespace
Symfony\Component\YamlCode
private static function parseSequence($sequence, &$i = 0, $references = array()) {
$output = array();
$len = strlen($sequence);
++$i;
// [foo, bar, ...]
while ($i < $len) {
switch ($sequence[$i]) {
case '[':
// nested sequence
$output[] = self::parseSequence($sequence, $i, $references);
break;
case '{':
// nested mapping
$output[] = self::parseMapping($sequence, $i, $references);
break;
case ']':
return $output;
case ',':
case ' ':
break;
default:
$isQuoted = in_array($sequence[$i], array(
'"',
"'",
));
$value = self::parseScalar($sequence, array(
',',
']',
), array(
'"',
"'",
), $i, true, $references);
// the value can be an array if a reference has been resolved to an array var
if (!is_array($value) && !$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$pos = 0;
$value = self::parseMapping('{' . $value . '}', $pos, $references);
} catch (\InvalidArgumentException $e) {
// no, it's not
}
}
$output[] = $value;
--$i;
}
++$i;
}
throw new ParseException(sprintf('Malformed inline YAML string %s', $sequence));
}