private static function Inline::parseSequence in Lockr 7.3
Parses a YAML sequence.
Parameters
string $sequence:
int $flags:
int &$i:
array $references:
Return value
array
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 value.
- Inline::parseMapping in vendor/
symfony/ yaml/ Inline.php - Parses a YAML mapping.
File
- vendor/
symfony/ yaml/ Inline.php, line 412
Class
- Inline
- Inline implements a YAML parser/dumper for the YAML inline syntax.
Namespace
Symfony\Component\YamlCode
private static function parseSequence($sequence, $flags, &$i = 0, $references = []) {
$output = [];
$len = \strlen($sequence);
++$i;
// [foo, bar, ...]
while ($i < $len) {
if (']' === $sequence[$i]) {
return $output;
}
if (',' === $sequence[$i] || ' ' === $sequence[$i]) {
++$i;
continue;
}
$tag = self::parseTag($sequence, $i, $flags);
switch ($sequence[$i]) {
case '[':
// nested sequence
$value = self::parseSequence($sequence, $flags, $i, $references);
break;
case '{':
// nested mapping
$value = self::parseMapping($sequence, $flags, $i, $references);
break;
default:
$isQuoted = \in_array($sequence[$i], [
'"',
"'",
]);
$value = self::parseScalar($sequence, $flags, [
',',
']',
], $i, null === $tag, $references);
// the value can be an array if a reference has been resolved to an array var
if (\is_string($value) && !$isQuoted && false !== strpos($value, ': ')) {
// embedded mapping?
try {
$pos = 0;
$value = self::parseMapping('{' . $value . '}', $flags, $pos, $references);
} catch (\InvalidArgumentException $e) {
// no, it's not
}
}
--$i;
}
if (null !== $tag) {
$value = new TaggedValue($tag, $value);
}
$output[] = $value;
++$i;
}
throw new ParseException(sprintf('Malformed inline YAML string: %s.', $sequence), self::$parsedLineNumber + 1, null, self::$parsedFilename);
}