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

FilterExpression's attributes are changed by the compiler #3895

Open
ericmorand opened this issue Oct 21, 2023 · 0 comments
Open

FilterExpression's attributes are changed by the compiler #3895

ericmorand opened this issue Oct 21, 2023 · 0 comments

Comments

@ericmorand
Copy link
Contributor

ericmorand commented Oct 21, 2023

While using TwigPHP to parse a Twig template and apply some changes to the AST before it is sent to the compiler, we discovered that the compiler changes somes attributes of FilterExpression:

$this->setAttribute('name', $name);

This is a violation of the purpose of a compiler: a compiler compiles an AST as-is without changing it. Would the AST needs to be changed, it must be done before it is sent to the compiler

This violation creates an obvious issue where changing the attributes of a FilterExpression node is reverted by the compiler - defeating the purpose of having an AST to begin with.

I'm not sure how spread this pattern is in TwigPHP code base. Hopefully not too much.

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

No branches or pull requests

1 participant