Skip to content

Commit 01f2e6e

Browse files
minor symfony#58116 bump requirement for Twig to 3.12+ (xabbuh)
This PR was merged into the 7.2 branch. Discussion ---------- bump requirement for Twig to 3.12+ | Q | A | ------------- | --- | Branch? | 7.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Issues | | License | MIT Commits ------- 6bbc96f bump requirement for Twig to 3.12+
2 parents dafb531 + 6bbc96f commit 01f2e6e

File tree

21 files changed

+65
-146
lines changed

21 files changed

+65
-146
lines changed

UPGRADE-7.2.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ Translation
6161

6262
* Deprecate passing an escape character to `CsvFileLoader::setCsvControl()`
6363

64+
TwigBridge
65+
----------
66+
67+
* Deprecate passing a tag to the constructor of `FormThemeNode`
68+
6469
Yaml
6570
----
6671

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.10",
42+
"twig/twig": "^3.12",
4343
"psr/cache": "^2.0|^3.0",
4444
"psr/clock": "^1.0",
4545
"psr/container": "^1.1|^2.0",

src/Symfony/Bridge/Twig/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
7.2
5+
---
6+
7+
* Deprecate passing a tag to the constructor of `FormThemeNode`
8+
49
7.1
510
---
611

src/Symfony/Bridge/Twig/Node/DumpNode.php

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Node;
1313

14-
use Twig\Attribute\FirstClassTwigCallableReady;
1514
use Twig\Attribute\YieldReady;
1615
use Twig\Compiler;
1716
use Twig\Node\Node;
@@ -26,18 +25,13 @@ public function __construct(
2625
private string $varPrefix,
2726
?Node $values,
2827
int $lineno,
29-
?string $tag = null,
3028
) {
3129
$nodes = [];
3230
if (null !== $values) {
3331
$nodes['values'] = $values;
3432
}
3533

36-
if (class_exists(FirstClassTwigCallableReady::class)) {
37-
parent::__construct($nodes, [], $lineno);
38-
} else {
39-
parent::__construct($nodes, [], $lineno, $tag);
40-
}
34+
parent::__construct($nodes, [], $lineno);
4135
}
4236

4337
public function compile(Compiler $compiler): void

src/Symfony/Bridge/Twig/Node/FormThemeNode.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
namespace Symfony\Bridge\Twig\Node;
1313

1414
use Symfony\Component\Form\FormRenderer;
15-
use Twig\Attribute\FirstClassTwigCallableReady;
1615
use Twig\Attribute\YieldReady;
1716
use Twig\Compiler;
1817
use Twig\Node\Node;
@@ -23,13 +22,19 @@
2322
#[YieldReady]
2423
final class FormThemeNode extends Node
2524
{
26-
public function __construct(Node $form, Node $resources, int $lineno, ?string $tag = null, bool $only = false)
25+
/**
26+
* @param bool $only
27+
*/
28+
public function __construct(Node $form, Node $resources, int $lineno, $only = false)
2729
{
28-
if (class_exists(FirstClassTwigCallableReady::class)) {
29-
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno);
30-
} else {
31-
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno, $tag);
30+
if (null === $only || \is_string($only)) {
31+
trigger_deprecation('twig/twig', '3.12', 'Passing a tag to %s() is deprecated.', __METHOD__);
32+
$only = \func_num_args() > 4 ? func_get_arg(4) : true;
33+
} elseif (!\is_bool($only)) {
34+
throw new \TypeError(\sprintf('Argument 4 passed to "%s()" must be a boolean, "%s" given.', __METHOD__, get_debug_type($only)));
3235
}
36+
37+
parent::__construct(['form' => $form, 'resources' => $resources], ['only' => $only], $lineno);
3338
}
3439

3540
public function compile(Compiler $compiler): void

src/Symfony/Bridge/Twig/Node/StopwatchNode.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Node;
1313

14-
use Twig\Attribute\FirstClassTwigCallableReady;
1514
use Twig\Attribute\YieldReady;
1615
use Twig\Compiler;
1716
use Twig\Node\Expression\AssignNameExpression;
@@ -25,13 +24,9 @@
2524
#[YieldReady]
2625
final class StopwatchNode extends Node
2726
{
28-
public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0, ?string $tag = null)
27+
public function __construct(Node $name, Node $body, AssignNameExpression $var, int $lineno = 0)
2928
{
30-
if (class_exists(FirstClassTwigCallableReady::class)) {
31-
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno);
32-
} else {
33-
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno, $tag);
34-
}
29+
parent::__construct(['body' => $body, 'name' => $name, 'var' => $var], [], $lineno);
3530
}
3631

3732
public function compile(Compiler $compiler): void

src/Symfony/Bridge/Twig/Node/TransDefaultDomainNode.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Node;
1313

14-
use Twig\Attribute\FirstClassTwigCallableReady;
1514
use Twig\Attribute\YieldReady;
1615
use Twig\Compiler;
1716
use Twig\Node\Expression\AbstractExpression;
@@ -23,13 +22,9 @@
2322
#[YieldReady]
2423
final class TransDefaultDomainNode extends Node
2524
{
26-
public function __construct(AbstractExpression $expr, int $lineno = 0, ?string $tag = null)
25+
public function __construct(AbstractExpression $expr, int $lineno = 0)
2726
{
28-
if (class_exists(FirstClassTwigCallableReady::class)) {
29-
parent::__construct(['expr' => $expr], [], $lineno);
30-
} else {
31-
parent::__construct(['expr' => $expr], [], $lineno, $tag);
32-
}
27+
parent::__construct(['expr' => $expr], [], $lineno);
3328
}
3429

3530
public function compile(Compiler $compiler): void

src/Symfony/Bridge/Twig/Node/TransNode.php

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Bridge\Twig\Node;
1313

14-
use Twig\Attribute\FirstClassTwigCallableReady;
1514
use Twig\Attribute\YieldReady;
1615
use Twig\Compiler;
1716
use Twig\Node\Expression\AbstractExpression;
@@ -27,7 +26,7 @@
2726
#[YieldReady]
2827
final class TransNode extends Node
2928
{
30-
public function __construct(Node $body, ?Node $domain = null, ?AbstractExpression $count = null, ?AbstractExpression $vars = null, ?AbstractExpression $locale = null, int $lineno = 0, ?string $tag = null)
29+
public function __construct(Node $body, ?Node $domain = null, ?AbstractExpression $count = null, ?AbstractExpression $vars = null, ?AbstractExpression $locale = null, int $lineno = 0)
3130
{
3231
$nodes = ['body' => $body];
3332
if (null !== $domain) {
@@ -43,11 +42,7 @@ public function __construct(Node $body, ?Node $domain = null, ?AbstractExpressio
4342
$nodes['locale'] = $locale;
4443
}
4544

46-
if (class_exists(FirstClassTwigCallableReady::class)) {
47-
parent::__construct($nodes, [], $lineno);
48-
} else {
49-
parent::__construct($nodes, [], $lineno, $tag);
50-
}
45+
parent::__construct($nodes, [], $lineno);
5146
}
5247

5348
public function compile(Compiler $compiler): void

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public function testCompile()
6868
trim($compiler->compile($node)->getSource())
6969
);
7070

71-
$node = new FormThemeNode($form, $resources, 0, null, true);
71+
$node = new FormThemeNode($form, $resources, 0, true);
7272

7373
$this->assertEquals(
7474
\sprintf(
@@ -90,7 +90,7 @@ public function testCompile()
9090
trim($compiler->compile($node)->getSource())
9191
);
9292

93-
$node = new FormThemeNode($form, $resources, 0, null, true);
93+
$node = new FormThemeNode($form, $resources, 0, true);
9494

9595
$this->assertEquals(
9696
\sprintf(

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

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515
use Symfony\Bridge\Twig\Node\SearchAndRenderBlockNode;
16-
use Twig\Attribute\FirstClassTwigCallableReady;
1716
use Twig\Compiler;
1817
use Twig\Environment;
1918
use Twig\Extension\CoreExtension;
@@ -33,11 +32,7 @@ public function testCompileWidget()
3332
new NameExpression('form', 0),
3433
]);
3534

36-
if (class_exists(FirstClassTwigCallableReady::class)) {
37-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0);
38-
} else {
39-
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
40-
}
35+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0);
4136

4237
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
4338

@@ -60,11 +55,7 @@ public function testCompileWidgetWithVariables()
6055
], 0),
6156
]);
6257

63-
if (class_exists(FirstClassTwigCallableReady::class)) {
64-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0);
65-
} else {
66-
$node = new SearchAndRenderBlockNode('form_widget', $arguments, 0);
67-
}
58+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_widget'), $arguments, 0);
6859

6960
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
7061

@@ -84,11 +75,7 @@ public function testCompileLabelWithLabel()
8475
new ConstantExpression('my label', 0),
8576
]);
8677

87-
if (class_exists(FirstClassTwigCallableReady::class)) {
88-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
89-
} else {
90-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
91-
}
78+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
9279

9380
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
9481

@@ -108,11 +95,7 @@ public function testCompileLabelWithNullLabel()
10895
new ConstantExpression(null, 0),
10996
]);
11097

111-
if (class_exists(FirstClassTwigCallableReady::class)) {
112-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
113-
} else {
114-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
115-
}
98+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
11699

117100
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
118101

@@ -134,11 +117,7 @@ public function testCompileLabelWithEmptyStringLabel()
134117
new ConstantExpression('', 0),
135118
]);
136119

137-
if (class_exists(FirstClassTwigCallableReady::class)) {
138-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
139-
} else {
140-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
141-
}
120+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
142121

143122
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
144123

@@ -159,11 +138,7 @@ public function testCompileLabelWithDefaultLabel()
159138
new NameExpression('form', 0),
160139
]);
161140

162-
if (class_exists(FirstClassTwigCallableReady::class)) {
163-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
164-
} else {
165-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
166-
}
141+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
167142

168143
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
169144

@@ -187,11 +162,7 @@ public function testCompileLabelWithAttributes()
187162
], 0),
188163
]);
189164

190-
if (class_exists(FirstClassTwigCallableReady::class)) {
191-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
192-
} else {
193-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
194-
}
165+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
195166

196167
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
197168

@@ -220,11 +191,7 @@ public function testCompileLabelWithLabelAndAttributes()
220191
], 0),
221192
]);
222193

223-
if (class_exists(FirstClassTwigCallableReady::class)) {
224-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
225-
} else {
226-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
227-
}
194+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
228195

229196
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
230197

@@ -252,11 +219,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNull()
252219
),
253220
]);
254221

255-
if (class_exists(FirstClassTwigCallableReady::class)) {
256-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
257-
} else {
258-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
259-
}
222+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
260223

261224
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
262225

@@ -294,11 +257,7 @@ public function testCompileLabelWithLabelThatEvaluatesToNullAndAttributes()
294257
], 0),
295258
]);
296259

297-
if (class_exists(FirstClassTwigCallableReady::class)) {
298-
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
299-
} else {
300-
$node = new SearchAndRenderBlockNode('form_label', $arguments, 0);
301-
}
260+
$node = new SearchAndRenderBlockNode(new TwigFunction('form_label'), $arguments, 0);
302261

303262
$compiler = new Compiler(new Environment($this->createMock(LoaderInterface::class)));
304263

0 commit comments

Comments
 (0)