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

Breadcrumb

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

function Parser::parseDeclaration

Parses a declaration

Return value

Node\Declaration|null

1 call to Parser::parseDeclaration()
Parser::parseStatementListItem in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a statement list item

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseDeclaration() {
    
    //Here the token value is checked for performance so that functions won't be
    
    //called if not necessary
    $token = $this->scanner
        ->getToken();
    if (!$token) {
        return null;
    }
    $val = $token->value;
    if ($declaration = $this->parseFunctionOrGeneratorDeclaration()) {
        return $declaration;
    }
    elseif ($val === "class" && ($declaration = $this->parseClassDeclaration())) {
        return $declaration;
    }
    elseif (($val === "let" || $val === "const") && ($declaration = $this->isolateContext(array(
        "allowIn" => true,
    ), "parseLexicalDeclaration"))) {
        return $declaration;
    }
    return null;
}

API Navigation

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