Automattic\WooCommerce\Vendor\GraphQL\Language

Lexer::positionAfterWhitespaceprivateWC 1.0

Reads from body starting at startPosition until it finds a non-whitespace or commented character, then places cursor to the position of that character.

Method of the class: Lexer{}

No Hooks.

Returns

null. Nothing (null).

Usage

// private - for code of main (parent) class only
$result = $this->positionAfterWhitespace(): void;

Lexer::positionAfterWhitespace() code WC 10.9.1

private function positionAfterWhitespace(): void
{
    while ($this->position < $this->source->length) {
        [, $code, $bytes] = $this->readChar();

        // Skip whitespace
        // tab | space | comma | BOM
        if (in_array($code, [9, 32, 44, 0xFEFF], true)) {
            $this->moveStringCursor(1, $bytes);
        } elseif ($code === 10) { // new line
            $this->moveStringCursor(1, $bytes);
            ++$this->line;
            $this->lineStart = $this->position;
        } elseif ($code === 13) { // carriage return
            [, $nextCode, $nextBytes] = $this->moveStringCursor(1, $bytes)->readChar();

            if ($nextCode === 10) { // lf after cr
                $this->moveStringCursor(1, $nextBytes);
            }

            ++$this->line;
            $this->lineStart = $this->position;
        } else {
            break;
        }
    }
}