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

Breadcrumb

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

function Parser::lexInlineQuotedString

3 calls to Parser::lexInlineQuotedString()
Parser::doParse in vendor/symfony/yaml/Parser.php
Parser::lexInlineStructure in vendor/symfony/yaml/Parser.php
Parser::parseValue in vendor/symfony/yaml/Parser.php
Parses a YAML value.

File

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

Class

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

Namespace

Symfony\Component\Yaml

Code

private function lexInlineQuotedString(int &$cursor = 0) : string {
    $quotation = $this->currentLine[$cursor];
    $value = $quotation;
    ++$cursor;
    $previousLineWasNewline = true;
    $previousLineWasTerminatedWithBackslash = false;
    $lineNumber = 0;
    do {
        if (++$lineNumber > 1) {
            $cursor += strspn($this->currentLine, ' ', $cursor);
        }
        if ($this->isCurrentLineBlank()) {
            $value .= "\n";
        }
        elseif (!$previousLineWasNewline && !$previousLineWasTerminatedWithBackslash) {
            $value .= ' ';
        }
        for (; \strlen($this->currentLine) > $cursor; ++$cursor) {
            switch ($this->currentLine[$cursor]) {
                case '\\':
                    if ("'" === $quotation) {
                        $value .= '\\';
                    }
                    elseif (isset($this->currentLine[++$cursor])) {
                        $value .= '\\' . $this->currentLine[$cursor];
                    }
                    break;
                case $quotation:
                    ++$cursor;
                    if ("'" === $quotation && isset($this->currentLine[$cursor]) && "'" === $this->currentLine[$cursor]) {
                        $value .= "''";
                        break;
                    }
                    return $value . $quotation;
                default:
                    $value .= $this->currentLine[$cursor];
            }
        }
        if ($this->isCurrentLineBlank()) {
            $previousLineWasNewline = true;
            $previousLineWasTerminatedWithBackslash = false;
        }
        elseif ('\\' === $this->currentLine[-1]) {
            $previousLineWasNewline = false;
            $previousLineWasTerminatedWithBackslash = true;
        }
        else {
            $previousLineWasNewline = false;
            $previousLineWasTerminatedWithBackslash = false;
        }
        if ($this->hasMoreLines()) {
            $cursor = 0;
        }
    } while ($this->moveToNextLine());
    throw new ParseException('Malformed inline YAML string.');
}

API Navigation

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