private static function Inline::parseSequence in Plug 7
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 lib/
Symfony/ yaml/ Symfony/ Component/ Yaml/ Inline.php - Converts a YAML string to a PHP array.
- Inline::parseMapping in lib/
Symfony/ yaml/ Symfony/ Component/ Yaml/ Inline.php - Parses a mapping to a YAML string.
File
- lib/
Symfony/ yaml/ Symfony/ Component/ 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));
}