Skip to content

Commit

Permalink
[TwigBridge][WebProfilerBundle] Require Twig 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabus committed May 3, 2024
1 parent eccdbea commit 6bcd771
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 14 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"ext-xml": "*",
"doctrine/event-manager": "^2",
"doctrine/persistence": "^3.1",
"twig/twig": "^3.0.4",
"twig/twig": "^3.9",
"psr/cache": "^2.0|^3.0",
"psr/clock": "^1.0",
"psr/container": "^1.1|^2.0",
Expand Down
4 changes: 1 addition & 3 deletions src/Symfony/Bridge/Twig/Node/TransNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,8 @@ public function compile(Compiler $compiler): void
$vars = null;
}
[$msg, $defaults] = $this->compileString($this->getNode('body'), $defaults, (bool) $vars);
$display = class_exists(YieldReady::class) ? 'yield' : 'echo';

$compiler
->write($display.' $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans(')
->write('yield $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans(')
->subcompile($msg)
;

Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ public function testCompileStrict()

$this->assertEquals(
sprintf(
'%s $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
class_exists(YieldReady::class) ? 'yield' : 'echo',
'yield $this->env->getExtension(\'Symfony\Bridge\Twig\Extension\TranslationExtension\')->trans("trans %%var%%", array_merge(["%%var%%" => %s], %s), "messages");',
$this->getVariableGetterWithoutStrictCheck('var'),
$this->getVariableGetterWithStrictCheck('foo')
),
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"require": {
"php": ">=8.2",
"symfony/translation-contracts": "^2.5|^3",
"twig/twig": "^3.0.4"
"twig/twig": "^3.9"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ private static function escape(Environment $env, string $s): string
}

// Twig 3.9
if (method_exists(EscaperExtension::class, 'escape')) {
return EscaperExtension::escape($env, $s);
}

// to be removed when support for Twig 3 is dropped
return twig_escape_filter($env, $s);
return EscaperExtension::escape($env, $s);

Check failure on line 118 in src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php:118:16: UndefinedMethod: Method Twig\Extension\EscaperExtension::escape does not exist (see https://psalm.dev/022)

Check failure on line 118 in src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php

View workflow job for this annotation

GitHub Actions / Psalm

UndefinedMethod

src/Symfony/Bundle/WebProfilerBundle/Twig/WebProfilerExtension.php:118:16: UndefinedMethod: Method Twig\Extension\EscaperExtension::escape does not exist (see https://psalm.dev/022)
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/WebProfilerBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"symfony/http-kernel": "^6.4|^7.0",
"symfony/routing": "^6.4|^7.0",
"symfony/twig-bundle": "^6.4|^7.0",
"twig/twig": "^3.0.4"
"twig/twig": "^3.9"
},
"require-dev": {
"symfony/browser-kit": "^6.4|^7.0",
Expand Down

0 comments on commit 6bcd771

Please sign in to comment.