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

Breadcrumb

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

function TestExpression::__construct

Overrides Node::__construct

2 calls to TestExpression::__construct()
DefinedTest::__construct in vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php
DefinedTest::__construct in vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php
1 method overrides TestExpression::__construct()
DefinedTest::__construct in vendor/twig/twig/src/Node/Expression/Test/DefinedTest.php

File

vendor/twig/twig/src/Node/Expression/TestExpression.php, line 22

Class

TestExpression

Namespace

Twig\Node\Expression

Code

public function __construct(Node $node, string|TwigTest $test, ?Node $arguments, int $lineno) {
    if (!$node instanceof AbstractExpression) {
        trigger_deprecation('twig/twig', '3.15', 'Not passing a "%s" instance to the "node" argument of "%s" is deprecated ("%s" given).', AbstractExpression::class, static::class, get_class($node));
    }
    $nodes = [
        'node' => $node,
    ];
    if (null !== $arguments) {
        $nodes['arguments'] = $arguments;
    }
    if ($test instanceof TwigTest) {
        $name = $test->getName();
    }
    else {
        $name = $test;
        trigger_deprecation('twig/twig', '3.12', 'Not passing an instance of "TwigTest" when creating a "%s" test of type "%s" is deprecated.', $name, static::class);
    }
    parent::__construct($nodes, [
        'name' => $name,
        'type' => 'test',
    ], $lineno);
    if ($test instanceof TwigTest) {
        $this->setAttribute('twig_callable', $test);
    }
    $this->deprecateAttribute('arguments', new NameDeprecation('twig/twig', '3.12'));
    $this->deprecateAttribute('callable', new NameDeprecation('twig/twig', '3.12'));
    $this->deprecateAttribute('is_variadic', new NameDeprecation('twig/twig', '3.12'));
    $this->deprecateAttribute('dynamic_name', new NameDeprecation('twig/twig', '3.12'));
}
RSS feed
Powered by Drupal