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

Breadcrumb

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

function Parser::parseSwitchStatement

Parses a switch statement

Return value

Node\SwitchStatement|null

1 call to Parser::parseSwitchStatement()
Parser::parseBreakableStatement in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a breakable statement

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseSwitchStatement() {
    if ($token = $this->scanner
        ->consume("switch")) {
        if ($this->scanner
            ->consume("(") && ($discriminant = $this->isolateContext(array(
            "allowIn" => true,
        ), "parseExpression")) && $this->scanner
            ->consume(")") && ($cases = $this->parseCaseBlock()) !== null) {
            $node = $this->createNode("SwitchStatement", $token);
            $node->setDiscriminant($discriminant);
            $node->setCases($cases);
            return $this->completeNode($node);
        }
        $this->error();
    }
    return null;
}

API Navigation

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