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

Breadcrumb

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

function Parser::parseArgumentList

Parses an arguments list

Return value

array|null

1 call to Parser::parseArgumentList()
Parser::parseArguments in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses an arguments list wrapped in round brackets

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseArgumentList() {
    $list = array();
    $hasComma = false;
    while (true) {
        $spread = $this->scanner
            ->consume("...");
        $exp = $this->isolateContext(array(
            "allowIn" => true,
        ), "parseAssignmentExpression");
        if (!$exp) {
            
            //If there's no expression and the spread dots have been found
            
            //or there is a trailing comma that is not allowed, throw an
            
            //error
            if ($spread || $hasComma && !$this->features->trailingCommaFunctionCallDeclaration) {
                $this->error();
            }
            break;
        }
        if ($spread) {
            $node = $this->createNode("SpreadElement", $spread);
            $node->setArgument($exp);
            $list[] = $this->completeNode($node);
        }
        else {
            $list[] = $exp;
        }
        if (!$this->scanner
            ->consume(",")) {
            break;
        }
        $hasComma = true;
    }
    return $list;
}

API Navigation

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