private function Parser::parseValue

Parses a YAML value.

Parameters

string $value A YAML value:

Return value

mixed A PHP value

Throws

ParseException When reference does not exist

1 call to Parser::parseValue()
Parser::parse in drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php
Parses a YAML string to a PHP value.

File

drupal/core/vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php, line 369

Class

Parser
Parser parses YAML strings to convert them to PHP arrays.

Namespace

Symfony\Component\Yaml

Code

private function parseValue($value) {
  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);
  } catch (ParseException $e) {
    $e
      ->setParsedLine($this
      ->getRealCurrentLineNb() + 1);
    $e
      ->setSnippet($this->currentLine);
    throw $e;
  }
}