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

Breadcrumb

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

function Parser::parseArrowFunction

Parses an arrow function

Return value

Node\ArrowFunctionExpression|null

1 call to Parser::parseArrowFunction()
Parser::parseAssignmentExpression in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses an assignment expression

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseArrowFunction() {
    $state = $this->scanner
        ->getState();
    $async = false;
    if ($this->features->asyncAwait && ($async = $this->checkAsyncFunctionStart(false))) {
        $this->scanner
            ->consumeToken();
    }
    if (($params = $this->parseArrowParameters()) !== null) {
        if ($this->scanner
            ->noLineTerminators() && $this->scanner
            ->consume("=>")) {
            if ($body = $this->parseConciseBody((bool) $async)) {
                if (is_array($params)) {
                    $pos = $params[1];
                    $params = $params[0];
                }
                else {
                    $pos = $params;
                    $params = array(
                        $params,
                    );
                }
                if ($async) {
                    $pos = $async;
                }
                $node = $this->createNode("ArrowFunctionExpression", $pos);
                $node->setParams($params);
                $node->setBody($body[0]);
                $node->setExpression($body[1]);
                $node->setAsync((bool) $async);
                return $this->completeNode($node);
            }
            $this->error();
        }
    }
    $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