public static function Inline::parseScalar in Service Container 7
Same name and namespace in other branches
- 7.2 modules/providers/service_container_symfony/lib/Symfony/Component/Yaml/Inline.php \Symfony\Component\Yaml\Inline::parseScalar()
Parses a scalar to a YAML string.
Parameters
string $scalar:
string $delimiters:
array $stringDelimiters:
int &$i:
bool $evaluate:
array $references:
Return value
string A YAML string
Throws
ParseException When malformed inline YAML string is parsed
6 calls to Inline::parseScalar()
- Inline::evaluateScalar in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php - Evaluates scalars and replaces magic values.
- Inline::parse in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php - Converts a YAML string to a PHP array.
- Inline::parseMapping in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php - Parses a mapping to a YAML string.
- Inline::parseSequence in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php - Parses a sequence to a YAML string.
- InlineTest::testParseScalarWithCorrectlyQuotedStringShouldReturnString in modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Tests/ InlineTest.php
File
- modules/
providers/ service_container_symfony/ lib/ Symfony/ Component/ Yaml/ Inline.php, line 208
Class
- Inline
- Inline implements a YAML parser/dumper for the YAML inline syntax.
Namespace
Symfony\Component\YamlCode
public static function parseScalar($scalar, $delimiters = null, $stringDelimiters = array(
'"',
"'",
), &$i = 0, $evaluate = true, $references = array()) {
if (in_array($scalar[$i], $stringDelimiters)) {
// quoted scalar
$output = self::parseQuotedScalar($scalar, $i);
if (null !== $delimiters) {
$tmp = ltrim(substr($scalar, $i), ' ');
if (!in_array($tmp[0], $delimiters)) {
throw new ParseException(sprintf('Unexpected characters (%s).', substr($scalar, $i)));
}
}
}
else {
// "normal" string
if (!$delimiters) {
$output = substr($scalar, $i);
$i += strlen($output);
// remove comments
if (false !== ($strpos = strpos($output, ' #'))) {
$output = rtrim(substr($output, 0, $strpos));
}
}
elseif (preg_match('/^(.+?)(' . implode('|', $delimiters) . ')/', substr($scalar, $i), $match)) {
$output = $match[1];
$i += strlen($output);
}
else {
throw new ParseException(sprintf('Malformed inline YAML string (%s).', $scalar));
}
if ($evaluate) {
$output = self::evaluateScalar($output, $references);
}
}
return $output;
}