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

Breadcrumb

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

function Parser::parseConditionalExpression

Parses a conditional expression

Return value

Node\Node|null

1 call to Parser::parseConditionalExpression()
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 3101

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseConditionalExpression() {
    if ($test = $this->parseLogicalBinaryExpression()) {
        if ($this->scanner
            ->consume("?")) {
            $consequent = $this->isolateContext(array(
                "allowIn" => true,
            ), "parseAssignmentExpression");
            if ($consequent && $this->scanner
                ->consume(":") && ($alternate = $this->parseAssignmentExpression())) {
                $node = $this->createNode("ConditionalExpression", $test);
                $node->setTest($test);
                $node->setConsequent($consequent);
                $node->setAlternate($alternate);
                return $this->completeNode($node);
            }
            $this->error();
        }
        else {
            return $test;
        }
    }
    return null;
}
RSS feed
Powered by Drupal