$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')); } public function compile(Compiler $compiler): void { $name = $this->getAttribute('name'); if ($this->hasAttribute('twig_callable')) { $name = $this->getAttribute('twig_callable')->getName(); if ($name !== $this->getAttribute('name')) { trigger_deprecation('twig/twig', '3.12', 'Changing the value of a "test" node in a NodeVisitor class is not supported anymore.'); $this->removeAttribute('twig_callable'); } } if (!$this->hasAttribute('twig_callable')) { $this->setAttribute('twig_callable', $compiler->getEnvironment()->getTest($this->getAttribute('name'))); } $this->compileCallable($compiler); } }