You are here

private function Parser::parseValue in Plug 7

Parses a YAML value.

Parameters

string $value A YAML value:

bool $exceptionOnInvalidType True if an exception must be thrown on invalid types false otherwise:

bool $objectSupport True if object support is enabled, false otherwise:

bool $objectForMap true if maps should return a stdClass instead of array():

Return value

mixed A PHP value

Throws

ParseException When reference does not exist

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

File

lib/Symfony/yaml/Symfony/Component/Yaml/Parser.php, line 444

Class

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

Namespace

Symfony\Component\Yaml

Code

private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $objectForMap) {
  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('/^' . self::FOLDED_SCALAR_PATTERN . '$/', $value, $matches)) {
    $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
    return $this
      ->parseFoldedScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), (int) abs($modifiers));
  }
  try {
    return Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
  } catch (ParseException $e) {
    $e
      ->setParsedLine($this
      ->getRealCurrentLineNb() + 1);
    $e
      ->setSnippet($this->currentLine);
    throw $e;
  }
}