Skip to content
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

Fixed Twig 3.x deprecations #621

Draft
wants to merge 3 commits into
base: 2.x
Choose a base branch
from

Conversation

adamwojs
Copy link
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

// wrap the default node in a |replace filter
$defaultNode = new FilterExpression(
$arguments[0],
new ConstantExpression('replace', $lineno),
new Node([$wrappingNodeArguments[0]]),
$env->getFilter('replace'),
Copy link
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