Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Parser.php

function Parser::parse

Same name in this branch
  1. 11.1.x vendor/sebastian/cli-parser/src/Parser.php \SebastianBergmann\CliParser\Parser::parse()
  2. 11.1.x vendor/sebastian/diff/src/Parser.php \SebastianBergmann\Diff\Parser::parse()
  3. 11.1.x vendor/egulias/email-validator/src/Parser.php \Egulias\EmailValidator\Parser::parse()
  4. 11.1.x vendor/nikic/php-parser/lib/PhpParser/Parser.php \PhpParser\Parser::parse()
  5. 11.1.x vendor/twig/twig/src/Parser.php \Twig\Parser::parse()
  6. 11.1.x vendor/symfony/css-selector/Parser/Parser.php \Symfony\Component\CssSelector\Parser\Parser::parse()
  7. 11.1.x vendor/mck89/peast/lib/Peast/Selector/Parser.php \Peast\Selector\Parser::parse()
  8. 11.1.x vendor/mck89/peast/lib/Peast/Syntax/Parser.php \Peast\Syntax\Parser::parse()

Parses a YAML string to a PHP value.

Parameters

string $value A YAML string:

int-mask-of<Yaml::PARSE_*> $flags A bit field of Yaml::PARSE_* constants to customize the YAML parser behavior:

Throws

ParseException If the YAML is not valid

1 call to Parser::parse()
Parser::parseFile in vendor/symfony/yaml/Parser.php
Parses a YAML file into a PHP value.

File

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

Class

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

Namespace

Symfony\Component\Yaml

Code

public function parse(string $value, int $flags = 0) : mixed {
    if (false === preg_match('//u', $value)) {
        throw new ParseException('The YAML value does not appear to be valid UTF-8.', -1, null, $this->filename);
    }
    $this->refs = [];
    try {
        $data = $this->doParse($value, $flags);
    } finally {
        $this->refsBeingParsed = [];
        $this->offset = 0;
        $this->lines = [];
        $this->currentLine = '';
        $this->numberOfParsedLines = 0;
        $this->refs = [];
        $this->skippedLineNumbers = [];
        $this->locallySkippedLineNumbers = [];
        $this->totalNumberOfLines = null;
    }
    return $data;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal