Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fixed Twig 3.x deprecations#621

Draft
adamwojs wants to merge 3 commits into
schmittjoh:2.xfrom
ibexa:twig_deprecations
Draft

Fixed Twig 3.x deprecations#621
adamwojs wants to merge 3 commits into
schmittjoh:2.xfrom
ibexa:twig_deprecations

Conversation

@adamwojs
Copy link
Copy Markdown
Contributor

@adamwojs adamwojs commented Feb 20, 2025

Q A
Bug fix? no
New feature? no
BC breaks? no
Deprecations? yes
Tests pass? no
Fixed tickets
License Apache2

Description

This PR fix the following Twig 3.x deprecations in triggered by \JMS\TranslationBundle\Twig\DefaultApplyingNodeVisitor:

  • Since twig/twig 3.12: Not 1passing an instance of "TwigFilter" when creating a "replace" filter of type "Twig\Node\Expression\FilterExpression" is deprecated.
  • Since twig/twig 3.15: Instantiating "Twig\Node\Node" directly is deprecated; the class will become abstract in 4.0.
  • Since twig/twig 3.17: "Twig\Node\Expression\ConditionalExpression" is deprecated; use "Twig\Node\Expression\Ternary\ConditionalTernary" instead.

image

PR is still work in progress.

Todos

  • Tests
  • Documentation
  • Changelog

 "Not passing an instance of "TwigFilter" when creating a "replace" filter of type "Twig\Node\Expression\FilterExpression" is deprecated." deprecation warning
@adamwojs adamwojs changed the base branch from master to 2.x February 20, 2025 18:33
@adamwojs adamwojs changed the title Twig 3.x deprecations Fixed Twig 3.x deprecations Feb 20, 2025
$arguments[0],
new ConstantExpression('replace', $lineno),
new Node([$wrappingNodeArguments[0]]),
$env->getFilter('replace'),
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Twig\Environment::getFilter method is considered as @internal, however I didn't find better way to retrieve TwigFilter instance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant