Verified Commit 973b6ec1 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3441331 by andypost, longwave, Spokje, xjm: Update to Twig 3.9

parent 449f6fbf
Loading
Loading
Loading
Loading
Loading
+16 −9
Original line number Diff line number Diff line
@@ -495,7 +495,7 @@
            "dist": {
                "type": "path",
                "url": "core",
                "reference": "c02a5aeb8449c7bf2c4a4f5bcf2898ea97e8e923"
                "reference": "4fe148819362f3734baaa8a09d58aad6730dc770"
            },
            "require": {
                "asm89/stack-cors": "^2.1",
@@ -541,7 +541,7 @@
                "symfony/serializer": "^7.0",
                "symfony/validator": "^7.0",
                "symfony/yaml": "^7.0",
                "twig/twig": "^3.5.0"
                "twig/twig": "^3.9.2"
            },
            "conflict": {
                "drush/drush": "<12.4.3"
@@ -4250,30 +4250,37 @@
        },
        {
            "name": "twig/twig",
            "version": "v3.8.0",
            "version": "v3.9.2",
            "source": {
                "type": "git",
                "url": "https://github.com/twigphp/Twig.git",
                "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d"
                "reference": "856cb5a6cfd6f3e4dc1f6c9a8f54e259503f7cf3"
            },
            "dist": {
                "type": "zip",
                "url": "https://api.github.com/repos/twigphp/Twig/zipball/9d15f0ac07f44dc4217883ec6ae02fd555c6f71d",
                "reference": "9d15f0ac07f44dc4217883ec6ae02fd555c6f71d",
                "url": "https://api.github.com/repos/twigphp/Twig/zipball/856cb5a6cfd6f3e4dc1f6c9a8f54e259503f7cf3",
                "reference": "856cb5a6cfd6f3e4dc1f6c9a8f54e259503f7cf3",
                "shasum": ""
            },
            "require": {
                "php": ">=7.2.5",
                "symfony/deprecation-contracts": "^2.5|^3",
                "symfony/polyfill-ctype": "^1.8",
                "symfony/polyfill-mbstring": "^1.3",
                "symfony/polyfill-php80": "^1.22"
            },
            "require-dev": {
                "psr/container": "^1.0|^2.0",
                "symfony/phpunit-bridge": "^5.4.9|^6.3|^7.0"
                "symfony/phpunit-bridge": "^5.4.9|^6.4|^7.0"
            },
            "type": "library",
            "autoload": {
                "files": [
                    "src/Resources/core.php",
                    "src/Resources/debug.php",
                    "src/Resources/escaper.php",
                    "src/Resources/string_loader.php"
                ],
                "psr-4": {
                    "Twig\\": "src/"
                }
@@ -4306,7 +4313,7 @@
            ],
            "support": {
                "issues": "https://github.com/twigphp/Twig/issues",
                "source": "https://github.com/twigphp/Twig/tree/v3.8.0"
                "source": "https://github.com/twigphp/Twig/tree/v3.9.2"
            },
            "funding": [
                {
@@ -4318,7 +4325,7 @@
                    "type": "tidelift"
                }
            ],
            "time": "2023-11-21T18:54:41+00:00"
            "time": "2024-04-17T14:16:25+00:00"
        }
    ],
    "packages-dev": [
+1 −1
Original line number Diff line number Diff line
@@ -60,6 +60,6 @@
        "symfony/var-dumper": "~v7.0.6",
        "symfony/var-exporter": "~v7.0.6",
        "symfony/yaml": "~v7.0.3",
        "twig/twig": "~v3.8.0"
        "twig/twig": "~v3.9.2"
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@
        "symfony/process": "^7.0",
        "symfony/polyfill-iconv": "^1.26",
        "symfony/yaml": "^7.0",
        "twig/twig": "^3.5.0",
        "twig/twig": "^3.9.2",
        "doctrine/annotations": "^2.0",
        "doctrine/lexer": "^2.0",
        "guzzlehttp/guzzle": "^7.5",
+3 −1
Original line number Diff line number Diff line
@@ -2,6 +2,7 @@

namespace Drupal\Core\Template;

use Twig\Attribute\YieldReady;
use Twig\Compiler;
use Twig\Error\SyntaxError;
use Twig\Node\CheckToStringNode;
@@ -25,6 +26,7 @@
 * @see https://twig-extensions.readthedocs.io/en/latest/i18n.html
 * @see https://github.com/fabpot/Twig-extensions
 */
#[YieldReady]
class TwigNodeTrans extends Node {

  /**
@@ -59,7 +61,7 @@ public function compile(Compiler $compiler) {
    }

    // Start writing with the function to be called.
    $compiler->write('echo ' . (empty($plural) ? 't' : '\Drupal::translation()->formatPlural') . '(');
    $compiler->write('yield ' . (empty($plural) ? 't' : '\Drupal::translation()->formatPlural') . '(');

    // Move the count to the beginning of the parameters list.
    if (!empty($plural)) {
+4 −4
Original line number Diff line number Diff line
@@ -7,7 +7,7 @@
use Twig\Node\Expression\FunctionExpression;
use Twig\Node\Node;
use Twig\Node\PrintNode;
use Twig\NodeVisitor\AbstractNodeVisitor;
use Twig\NodeVisitor\NodeVisitorInterface;

/**
 * Provides a TwigNodeVisitor to change the generated parse-tree.
@@ -18,7 +18,7 @@
 *
 * @see twig_render
 */
class TwigNodeVisitor extends AbstractNodeVisitor {
class TwigNodeVisitor implements NodeVisitorInterface {

  /**
   * Tracks whether there is a render array aware filter active already.
@@ -28,14 +28,14 @@ class TwigNodeVisitor extends AbstractNodeVisitor {
  /**
   * {@inheritdoc}
   */
  protected function doEnterNode(Node $node, Environment $env) {
  public function enterNode(Node $node, Environment $env): Node {
    return $node;
  }

  /**
   * {@inheritdoc}
   */
  protected function doLeaveNode(Node $node, Environment $env) {
  public function leaveNode(Node $node, Environment $env): ?Node {
    // We use this to inject a call to render_var -> TwigExtension->renderVar()
    // before anything is printed.
    if ($node instanceof PrintNode) {
Loading