You are here

private static function Inline::parseTag in Lockr 7.3

Parameters

string $value:

int &$i:

int $flags:

Return value

string|null

3 calls to Inline::parseTag()
Inline::parse in vendor/symfony/yaml/Inline.php
Converts a YAML string to a PHP value.
Inline::parseMapping in vendor/symfony/yaml/Inline.php
Parses a YAML mapping.
Inline::parseSequence in vendor/symfony/yaml/Inline.php
Parses a YAML sequence.

File

vendor/symfony/yaml/Inline.php, line 795

Class

Inline
Inline implements a YAML parser/dumper for the YAML inline syntax.

Namespace

Symfony\Component\Yaml

Code

private static function parseTag($value, &$i, $flags) {
  if ('!' !== $value[$i]) {
    return;
  }
  $tagLength = strcspn($value, " \t\n", $i + 1);
  $tag = substr($value, $i + 1, $tagLength);
  $nextOffset = $i + $tagLength + 1;
  $nextOffset += strspn($value, ' ', $nextOffset);

  // Is followed by a scalar
  if ((!isset($value[$nextOffset]) || !\in_array($value[$nextOffset], [
    '[',
    '{',
  ], true)) && 'tagged' !== $tag) {

    // Manage non-whitelisted scalars in {@link self::evaluateScalar()}
    return;
  }

  // Built-in tags
  if ($tag && '!' === $tag[0]) {
    throw new ParseException(sprintf('The built-in tag "!%s" is not implemented.', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
  }
  if (Yaml::PARSE_CUSTOM_TAGS & $flags) {
    $i = $nextOffset;
    return $tag;
  }
  throw new ParseException(sprintf('Tags support is not enabled. Enable the `Yaml::PARSE_CUSTOM_TAGS` flag to use "!%s".', $tag), self::$parsedLineNumber + 1, $value, self::$parsedFilename);
}