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

Breadcrumb

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

function Parser::parseForDeclaration

Parses a let or const declaration in a for statement definition

Return value

Node\VariableDeclaration|null

1 call to Parser::parseForDeclaration()
Parser::parseForLetConstStatement in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a for(let ...) or for(const ...) statement

File

vendor/mck89/peast/lib/Peast/Syntax/Parser.php, line 1935

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseForDeclaration() {
    $state = $this->scanner
        ->getState();
    if ($token = $this->scanner
        ->consumeOneOf(array(
        "let",
        "const",
    ))) {
        if ($declaration = $this->parseForBinding()) {
            $node = $this->createNode("VariableDeclaration", $token);
            $node->setKind($token->value);
            $node->setDeclarations(array(
                $declaration,
            ));
            return $this->completeNode($node);
        }
        // "let" can be used as variable name in non-strict mode
        if ($this->scanner
            ->getStrictMode() || $token->value !== "let") {
            $this->error();
        }
        else {
            $this->scanner
                ->setState($state);
        }
    }
    return null;
}

API Navigation

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