Skip to content

allow Twig 4 #58145

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.12",
"twig/twig": "^3.12|^4.0",
"psr/cache": "^2.0|^3.0",
"psr/clock": "^1.0",
"psr/container": "^1.1|^2.0",
Expand Down
6 changes: 6 additions & 0 deletions src/Symfony/Bridge/Twig/Tests/Node/TransNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Twig\Loader\LoaderInterface;
use Twig\Node\Expression\NameExpression;
use Twig\Node\TextNode;
use Twig\Runtime\LoopIterator;

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

protected function getVariableGetterWithStrictCheck($name)
{
if (class_exists(LoopIterator::class)) {
return \sprintf('(array_key_exists("%1$s", $context) ? $context["%1$s"] : throw new RuntimeError(\'Variable "%1$s" does not exist.\', 0, $this->source))', $name);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest adding a comment to make it clear that the code path below is for Twig 3.x and older (allowing to clean this method when dropping support for Twig 3)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added one

}

// for Twig 3 and older, can be removed when support for Twig 3 is dropped
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);
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"php": ">=8.2",
"symfony/deprecation-contracts": "^2.5|^3",
"symfony/translation-contracts": "^2.5|^3",
"twig/twig": "^3.12"
"twig/twig": "^3.12|^4.0"
},
"require-dev": {
"egulias/email-validator": "^2.1.10|^3|^4",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/FrameworkBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
"symfony/web-link": "^6.4|^7.0",
"symfony/webhook": "^7.2",
"phpdocumentor/reflection-docblock": "^3.0|^4.0|^5.0",
"twig/twig": "^3.12"
"twig/twig": "^3.12|^4.0"
},
"conflict": {
"doctrine/persistence": "<1.3",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/SecurityBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"symfony/twig-bridge": "^6.4|^7.0",
"symfony/validator": "^6.4|^7.0",
"symfony/yaml": "^6.4|^7.0",
"twig/twig": "^3.12",
"twig/twig": "^3.12|^4.0",
"web-token/jwt-library": "^3.3.2|^4.0"
},
"conflict": {
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bundle/TwigBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"symfony/twig-bridge": "^6.4|^7.0",
"symfony/http-foundation": "^6.4|^7.0",
"symfony/http-kernel": "^6.4|^7.0",
"twig/twig": "^3.12"
"twig/twig": "^3.12|^4.0"
},
"require-dev": {
"symfony/asset": "^6.4|^7.0",
Expand Down
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.12"
"twig/twig": "^3.12|^4.0"
},
"require-dev": {
"symfony/browser-kit": "^6.4|^7.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"symfony/var-dumper": "^6.4|^7.0",
"symfony/var-exporter": "^6.4|^7.0",
"psr/cache": "^1.0|^2.0|^3.0",
"twig/twig": "^3.12"
"twig/twig": "^3.12|^4.0"
},
"provide": {
"psr/log-implementation": "1.0|2.0|3.0"
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/VarDumper/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"symfony/http-kernel": "^6.4|^7.0",
"symfony/process": "^6.4|^7.0",
"symfony/uid": "^6.4|^7.0",
"twig/twig": "^3.12"
"twig/twig": "^3.12|^4.0"
},
"conflict": {
"symfony/console": "<6.4"
Expand Down
Loading