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

Breadcrumb

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

function Parser::parseCatch

Parses the catch block of a try-catch statement

Return value

Node\CatchClause|null

1 call to Parser::parseCatch()
Parser::parseTryStatement in vendor/mck89/peast/lib/Peast/Syntax/Parser.php
Parses a try-catch statement

File

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

Class

Parser
Parser class

Namespace

Peast\Syntax

Code

protected function parseCatch() {
    if ($token = $this->scanner
        ->consume("catch")) {
        $node = $this->createNode("CatchClause", $token);
        if ($this->scanner
            ->consume("(")) {
            if (!($param = $this->parseCatchParameter()) || !$this->scanner
                ->consume(")")) {
                $this->error();
            }
            $node->setParam($param);
        }
        elseif (!$this->features->optionalCatchBinding) {
            $this->error();
        }
        if (!($body = $this->parseBlock())) {
            $this->error();
        }
        $node->setBody($body);
        return $this->completeNode($node);
    }
    return null;
}

API Navigation

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