Skip to content

Commit 8d8fbb0

Browse files
committed
feature symfony#58145 allow Twig 4 (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- allow Twig 4 | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT Commits ------- 1932601 allow Twig 4
2 parents cc11de0 + 1932601 commit 8d8fbb0

File tree

9 files changed

+14
-8
lines changed

9 files changed

+14
-8
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
"ext-xml": "*",
4040
"doctrine/event-manager": "^2",
4141
"doctrine/persistence": "^3.1",
42-
"twig/twig": "^3.12",
42+
"twig/twig": "^3.12|^4.0",
4343
"psr/cache": "^2.0|^3.0",
4444
"psr/clock": "^1.0",
4545
"psr/container": "^1.1|^2.0",

src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Twig\Loader\LoaderInterface;
1919
use Twig\Node\Expression\NameExpression;
2020
use Twig\Node\TextNode;
21+
use Twig\Runtime\LoopIterator;
2122

2223
/**
2324
* @author Asmir Mustafic <goetas@gmail.com>
@@ -50,6 +51,11 @@ protected function getVariableGetterWithoutStrictCheck($name)
5051

5152
protected function getVariableGetterWithStrictCheck($name)
5253
{
54+
if (class_exists(LoopIterator::class)) {
55+
return \sprintf('(array_key_exists("%1$s", $context) ? $context["%1$s"] : throw new RuntimeError(\'Variable "%1$s" does not exist.\', 0, $this->source))', $name);
56+
}
57+
58+
// for Twig 3 and older, can be removed when support for Twig 3 is dropped
5359
return \sprintf('(isset($context["%1$s"]) || array_key_exists("%1$s", $context) ? $context["%1$s"] : (function () { throw new RuntimeError(\'Variable "%1$s" does not exist.\', 0, $this->source); })())', $name);
5460
}
5561
}

src/Symfony/Bridge/Twig/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
"php": ">=8.2",
2020
"symfony/deprecation-contracts": "^2.5|^3",
2121
"symfony/translation-contracts": "^2.5|^3",
22-
"twig/twig": "^3.12"
22+
"twig/twig": "^3.12|^4.0"
2323
},
2424
"require-dev": {
2525
"egulias/email-validator": "^2.1.10|^3|^4",

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
"symfony/web-link": "^6.4|^7.0",
7474
"symfony/webhook": "^7.2",
7575
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
76-
"twig/twig": "^3.12"
76+
"twig/twig": "^3.12|^4.0"
7777
},
7878
"conflict": {
7979
"doctrine/persistence": "<1.3",

src/Symfony/Bundle/SecurityBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
"symfony/twig-bridge": "^6.4|^7.0",
5151
"symfony/validator": "^6.4|^7.0",
5252
"symfony/yaml": "^6.4|^7.0",
53-
"twig/twig": "^3.12",
53+
"twig/twig": "^3.12|^4.0",
5454
"web-token/jwt-library": "^3.3.2|^4.0"
5555
},
5656
"conflict": {

src/Symfony/Bundle/TwigBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"symfony/twig-bridge": "^6.4|^7.0",
2424
"symfony/http-foundation": "^6.4|^7.0",
2525
"symfony/http-kernel": "^6.4|^7.0",
26-
"twig/twig": "^3.12"
26+
"twig/twig": "^3.12|^4.0"
2727
},
2828
"require-dev": {
2929
"symfony/asset": "^6.4|^7.0",

src/Symfony/Bundle/WebProfilerBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"symfony/http-kernel": "^6.4|^7.0",
2323
"symfony/routing": "^6.4|^7.0",
2424
"symfony/twig-bundle": "^6.4|^7.0",
25-
"twig/twig": "^3.12"
25+
"twig/twig": "^3.12|^4.0"
2626
},
2727
"require-dev": {
2828
"symfony/browser-kit": "^6.4|^7.0",

src/Symfony/Component/HttpKernel/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
"symfony/var-dumper": "^6.4|^7.0",
4848
"symfony/var-exporter": "^6.4|^7.0",
4949
"psr/cache": "^1.0|^2.0|^3.0",
50-
"twig/twig": "^3.12"
50+
"twig/twig": "^3.12|^4.0"
5151
},
5252
"provide": {
5353
"psr/log-implementation": "1.0|2.0|3.0"

src/Symfony/Component/VarDumper/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
"symfony/http-kernel": "^6.4|^7.0",
2626
"symfony/process": "^6.4|^7.0",
2727
"symfony/uid": "^6.4|^7.0",
28-
"twig/twig": "^3.12"
28+
"twig/twig": "^3.12|^4.0"
2929
},
3030
"conflict": {
3131
"symfony/console": "<6.4"

0 commit comments

Comments
 (0)