: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
* This file is part of Twig.
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
namespace WPML\Core\Twig\TokenParser;
use WPML\Core\Twig\Error\SyntaxError;
use WPML\Core\Twig\Node\Expression\ConstantExpression;
use WPML\Core\Twig\Node\Node;
use WPML\Core\Twig\Token;
* Imports blocks defined in another template into the current template.
* {% extends "base.html" %}
* {% use "blocks.html" %}
* {% block title %}{% endblock %}
* {% block content %}{% endblock %}
* @see https://twig.symfony.com/doc/templates.html#horizontal-reuse for details.
class UseTokenParser extends \WPML\Core\Twig\TokenParser\AbstractTokenParser
public function parse(\WPML\Core\Twig\Token $token)
$template = $this->parser->getExpressionParser()->parseExpression();
$stream = $this->parser->getStream();
if (!$template instanceof \WPML\Core\Twig\Node\Expression\ConstantExpression) {
throw new \WPML\Core\Twig\Error\SyntaxError('The template references in a "use" statement must be a string.', $stream->getCurrent()->getLine(), $stream->getSourceContext());
if ($stream->nextIf('with')) {
$name = $stream->expect(\WPML\Core\Twig\Token::NAME_TYPE)->getValue();
if ($stream->nextIf('as')) {
$alias = $stream->expect(\WPML\Core\Twig\Token::NAME_TYPE)->getValue();
$targets[$name] = new \WPML\Core\Twig\Node\Expression\ConstantExpression($alias, -1);
if (!$stream->nextIf(\WPML\Core\Twig\Token::PUNCTUATION_TYPE, ',')) {
$stream->expect(\WPML\Core\Twig\Token::BLOCK_END_TYPE);
$this->parser->addTrait(new \WPML\Core\Twig\Node\Node(['template' => $template, 'targets' => new \WPML\Core\Twig\Node\Node($targets)]));
return new \WPML\Core\Twig\Node\Node();
\class_alias('WPML\\Core\\Twig\\TokenParser\\UseTokenParser', 'WPML\\Core\\Twig_TokenParser_Use');