Skip to content

Commit cedf9c8

Browse files
committed
minor #2114 [TwigComponent] Remove $tag parameter from *Node, as it is now deprecated by twig/twig 3.12 (Kocal)
This PR was merged into the 2.x branch. Discussion ---------- [TwigComponent] Remove `$tag` parameter from `*Node`, as it is now deprecated by twig/twig 3.12 | Q | A | ------------- | --- | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Issues | Fix #... <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT This PR fix the deprecations added in twig/twig 3.12, about the `$tag` parameter from `Node` class: ``` ➜ TwigComponent git:(2.x) sf php vendor/bin/simple-phpunit PHPUnit 9.6.20 by Sebastian Bergmann and contributors. Testing ............................................................... 63 / 249 ( 25%) ............................................................... 126 / 249 ( 50%) ............................................................... 189 / 249 ( 75%) ............................................................ 249 / 249 (100%) Time: 00:00.514, Memory: 38.00 MB OK (249 tests, 632 assertions) Remaining direct deprecation notices (39) 28x: Since twig/twig 3.12: The "tag" constructor argument of the "Symfony\UX\TwigComponent\Twig\ComponentNode" class is deprecated and ignored (check which TokenParser class set it to "component"), the tag is now automatically set by the Parser when needed. 5x in EmbeddedComponentTest::testPassingDownBlocksMultipleLevelsNeedsToBeDoneManually from Symfony\UX\TwigComponent\Tests\Integration 3x in EmbeddedComponentTest::testDeepNesting from Symfony\UX\TwigComponent\Tests\Integration 3x in EmbeddedComponentTest::testItCanHandleMissingOuterBlocks from Symfony\UX\TwigComponent\Tests\Integration 3x in EmbeddedComponentTest::testBlockDefinitionCanAccessTheContextOfTheDestinationBlocks from Symfony\UX\TwigComponent\Tests\Integration 2x in EmbeddedComponentTest::testABlockIsNotPassedIntoAnEmbeddedComponent from Symfony\UX\TwigComponent\Tests\Integration ... 11x: Since twig/twig 3.12: The "tag" constructor argument of the "Symfony\UX\TwigComponent\Twig\PropsNode" class is deprecated and ignored (check which TokenParser class set it to "props"), the tag is now automatically set by the Parser when needed. 10x in ComponentPropsParserTest::testPropsData from Symfony\UX\TwigComponent\Tests\Integration\Twig 1x in TwigComponentDebugCommandTest::testWithAnonymousComponent from Symfony\UX\TwigComponent\Tests\Integration\Command Legacy deprecation notices (4) ➜ TwigComponent git:(2.x) ``` Commits ------- 4057b11 [TwigComponent] Remove `$tag` parameter from `*Node`, as it is now deprecated by twig/twig 3.12
2 parents 6372df0 + 4057b11 commit cedf9c8

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/TwigComponent/src/Twig/ComponentNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@
2929
#[YieldReady]
3030
final class ComponentNode extends Node implements NodeOutputInterface
3131
{
32-
public function __construct(string $component, string $embeddedTemplateName, int $embeddedTemplateIndex, ?AbstractExpression $props, bool $only, int $lineno, string $tag)
32+
public function __construct(string $component, string $embeddedTemplateName, int $embeddedTemplateIndex, ?AbstractExpression $props, bool $only, int $lineno)
3333
{
3434
$nodes = [];
3535
if (null !== $props) {
3636
$nodes['props'] = $props;
3737
}
3838

39-
parent::__construct($nodes, [], $lineno, $tag);
39+
parent::__construct($nodes, [], $lineno);
4040

4141
$this->setAttribute('only', $only);
4242
$this->setAttribute('embedded_template', $embeddedTemplateName);

src/TwigComponent/src/Twig/ComponentTokenParser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function parse(Token $token): Node
6767

6868
$stream->expect(Token::BLOCK_END_TYPE);
6969

70-
return new ComponentNode($componentName, $module->getTemplateName(), $module->getAttribute('index'), $propsExpression, $only, $token->getLine(), $this->getTag());
70+
return new ComponentNode($componentName, $module->getTemplateName(), $module->getAttribute('index'), $propsExpression, $only, $token->getLine());
7171
}
7272

7373
public function getTag(): string

src/TwigComponent/src/Twig/PropsNode.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
#[YieldReady]
2424
class PropsNode extends Node
2525
{
26-
public function __construct(array $propsNames, array $values, $lineno = 0, ?string $tag = null)
26+
public function __construct(array $propsNames, array $values, $lineno = 0)
2727
{
28-
parent::__construct($values, ['names' => $propsNames], $lineno, $tag);
28+
parent::__construct($values, ['names' => $propsNames], $lineno);
2929
}
3030

3131
public function compile(Compiler $compiler): void

0 commit comments

Comments
 (0)