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

Breadcrumb

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

function TempNameExpression::__construct

Overrides Node::__construct

File

vendor/twig/twig/src/Node/Expression/TempNameExpression.php, line 21

Class

TempNameExpression

Namespace

Twig\Node\Expression

Code

public function __construct(string|int|null $name, int $lineno) {
    // All names supported by ExpressionParser::parsePrimaryExpression() should be excluded
    if ($name && \in_array(strtolower($name), [
        'true',
        'false',
        'none',
        'null',
    ])) {
        throw new SyntaxError(\sprintf('You cannot assign a value to "%s".', $name), $lineno);
    }
    if (self::class === static::class) {
        trigger_deprecation('twig/twig', '3.15', 'The "%s" class is deprecated.', self::class);
    }
    if (null !== $name && (is_int($name) || ctype_digit($name))) {
        $name = (int) $name;
    }
    elseif (in_array($name, self::RESERVED_NAMES)) {
        $name = "͜" . $name;
    }
    parent::__construct([], [
        'name' => $name,
    ], $lineno);
}
RSS feed
Powered by Drupal