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

Breadcrumb

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

function ExpressionParser::__construct

File

vendor/twig/twig/src/ExpressionParser.php, line 64

Class

ExpressionParser
Parses expressions.

Namespace

Twig

Code

public function __construct(Parser $parser, Environment $env) {
    $this->unaryOperators = $env->getUnaryOperators();
    $this->binaryOperators = $env->getBinaryOperators();
    $ops = [];
    foreach ($this->unaryOperators as $n => $c) {
        $ops[] = $c + [
            'name' => $n,
            'type' => 'unary',
        ];
    }
    foreach ($this->binaryOperators as $n => $c) {
        $ops[] = $c + [
            'name' => $n,
            'type' => 'binary',
        ];
    }
    foreach ($ops as $config) {
        if (!isset($config['precedence_change'])) {
            continue;
        }
        $name = $config['type'] . '_' . $config['name'];
        $min = min($config['precedence_change']->getNewPrecedence(), $config['precedence']);
        $max = max($config['precedence_change']->getNewPrecedence(), $config['precedence']);
        foreach ($ops as $c) {
            if ($c['precedence'] > $min && $c['precedence'] < $max) {
                $this->precedenceChanges[$c['type'] . '_' . $c['name']][] = $name;
            }
        }
    }
}

API Navigation

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