8000 [TwigBridge] fix Twig 3.17 compatibility by xabbuh · Pull Request #59058 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[TwigBridge] fix Twig 3.17 compatibility #59058

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
Dec 2, 2024
Merged
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
fix Twig 3.17 compatibility
  • Loading branch information
xabbuh committed Dec 2, 2024
commit ac4ca4616bf0dd18eb35d1b79b3a11a947d694e6
88 changes: 49 additions & 39 deletions src/Symfony/Bridge/Twig/Tests/Node/SearchAndRenderBlockNodeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Twig\Node\Expression\ConditionalExpression;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\NameExpression;
use Twig\Node\Expression\Ternary\ConditionalTernary;
use Twig\Node\Expression\Variable\ContextVariable;
use Twig\Node\Node;
use Twig\Node\Nodes;
Expand Down Expand Up @@ -308,32 +309,32 @@ public function testCompileLabelWithLabelAndAttributes()

public function testCompileLabelWithLabelThatEvaluatesToNull()
{
if (class_exists(ConditionalTernary::class)) {
$conditional = new ConditionalTernary(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
);
} else {
$conditional = new ConditionalExpression(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
);
}

if (class_exists(Nodes::class)) {
$arguments = new Nodes([
new ContextVariable('form', 0),
new ConditionalExpression(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
),
]);
$arguments = new Nodes([new ContextVariable('form', 0), $conditional]);
} else {
$arguments = new Node([
new NameExpression('form', 0),
new ConditionalExpression(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
),
]);
$arguments = new Node([new NameExpression('form', 0), $conditional]);
}

if (class_exists(FirstClassTwigCallableReady::class)) {
Expand All @@ -359,18 +360,32 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()

public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
{
if (class_exists(ConditionalTernary::class)) {
$conditional = new ConditionalTernary(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
);
} else {
$conditional = new ConditionalExpression(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
);
}

if (class_exists(Nodes::class)) {
$arguments = new Nodes([
new ContextVariable('form', 0),
new ConditionalExpression(
// if
new ConstantExpression(true, 0),
// then
new ConstantExpression(null, 0),
// else
new ConstantExpression(null, 0),
0
),
$conditional,
new ArrayExpression([
new ConstantExpression('foo', 0),
new ConstantExpression('bar', 0),
Expand All @@ -381,12 +396,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
} else {
$arguments = new Node([
new NameExpression('form', 0),
new ConditionalExpression(
new ConstantExpression(true, 0),
new ConstantExpression(null, 0),
new ConstantExpression(null, 0),
0
),
$conditional,
new ArrayExpression([
new ConstantExpression('foo', 0),
new ConstantExpression('bar', 0),
Expand Down
0