You are here

private function Parser::parseValue in Loft Data Grids 7.2

Same name and namespace in other branches
  1. 6.2 vendor/symfony/yaml/Symfony/Component/Yaml/Parser.php \Symfony\Component\Yaml\Parser::parseValue()

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():

string $context The parser context (either sequence or mapping):

Return value

mixed A PHP value

Throws

ParseException When reference does not exist

1 call to Parser::parseValue()
Parser::doParse in vendor/symfony/yaml/Parser.php

File

vendor/symfony/yaml/Parser.php, line 513

Class

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

Namespace

Symfony\Component\Yaml

Code

private function parseValue($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $context) {
  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->currentLineNb + 1, $this->currentLine);
    }
    return $this->refs[$value];
  }
  if (self::preg_match('/^' . self::BLOCK_SCALAR_HEADER_PATTERN . '$/', $value, $matches)) {
    $modifiers = isset($matches['modifiers']) ? $matches['modifiers'] : '';
    return $this
      ->parseBlockScalar($matches['separator'], preg_replace('#\\d+#', '', $modifiers), (int) abs($modifiers));
  }
  try {
    $parsedValue = Inline::parse($value, $exceptionOnInvalidType, $objectSupport, $objectForMap, $this->refs);
    if ('mapping' === $context && '"' !== $value[0] && "'" !== $value[0] && '[' !== $value[0] && '{' !== $value[0] && '!' !== $value[0] && false !== strpos($parsedValue, ': ')) {
      @trigger_error(sprintf('Using a colon in the unquoted mapping value "%s" in line %d is deprecated since Symfony 2.8 and will throw a ParseException in 3.0.', $value, $this
        ->getRealCurrentLineNb() + 1), E_USER_DEPRECATED);

      // to be thrown in 3.0
      // throw new ParseException('A colon cannot be used in an unquoted mapping value.');
    }
    return $parsedValue;
  } catch (ParseException $e) {
    $e
      ->setParsedLine($this
      ->getRealCurrentLineNb() + 1);
    $e
      ->setSnippet($this->currentLine);
    throw $e;
  }
}