private function Parser::parseValue in Translation template extractor 6.3
Same name and namespace in other branches
- 7.3 vendor/Symfony/Component/Yaml/Parser.php \Symfony\Component\Yaml\Parser::parseValue()
- 7.2 vendor/Symfony/Component/Yaml/Parser.php \Symfony\Component\Yaml\Parser::parseValue()
Parses a YAML value.
Parameters
string $value A YAML value:
Boolean $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise:
Boolean $objectSupport True if object support is enabled, false otherwise:
Return value
mixed A PHP value
Throws
ParseException When reference does not exist
1 call to Parser::parseValue()
- Parser::parse in vendor/
Symfony/ Component/ Yaml/ Parser.php - Parses a YAML string to a PHP value.
File
- vendor/
Symfony/ Component/ Yaml/ Parser.php, line 376
Class
- Parser
- Parser parses YAML strings to convert them to PHP arrays.
Namespace
Symfony\Component\YamlCode
private function parseValue($value, $exceptionOnInvalidType, $objectSupport) {
if (0 === strpos($value, '*')) {
if (false !== ($pos = strpos($value, '#'))) {
$value = substr($value, 1, $pos - 2);
}
else {
$value = substr($value, 1);
}
if (!array_key_exists($value, $this->refs)) {
throw new ParseException(sprintf('Reference "%s" does not exist.', $value), $this->currentLine);
}
return $this->refs[$value];
}
if (preg_match('/^(?P<separator>\\||>)(?P<modifiers>\\+|\\-|\\d+|\\+\\d+|\\-\\d+|\\d+\\+|\\d+\\-)?(?P<comments> +#.*)?$/', $value, $matches)) {
$modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
return $this
->parseFoldedScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), intval(abs($modifiers)));
}
try {
return Inline::parse($value, $exceptionOnInvalidType, $objectSupport);
} catch (ParseException $e) {
$e
->setParsedLine($this
->getRealCurrentLineNb() + 1);
$e
->setSnippet($this->currentLine);
throw $e;
}
}