twigphp / Twig

Twig, the flexible, fast, and secure template language for PHP
https://twig.symfony.com/
BSD 3-Clause "New" or "Revised" License
8.18k stars 1.25k forks source link

Introduce a CorrectnessNodeVisitor to validate that templates are semantically correct #4292

Open fabpot opened 2 months ago

fabpot commented 2 months ago

This PR addresses several issues around the correctness of templates. Being able to parse and compile a template does not mean that it is semantically correct. To enforce correctness, we currently have several places where we deal with it:

This PR introduces a new CorrectnessNodeVisitor that has the responsibility to check that a template is semantically correct. It's the continuation of work that started a long time ago in #2687 (where I mentioned the weirdness of some supported templates like those mentioned in #3926 and deprecated by this PR).

Closes #3698: Having a use tag embedded in another tag (like if in the mentioned PR) is deprecated and will not be possible in 4.0.

stof commented 1 month ago

@fabpot what is the state of this PR ? Do you plan to fix it or to abandon it ?

fabpot commented 1 month ago

@fabpot what is the state of this PR ? Do you plan to fix it or to abandon it ?

I plan to still work on this (soon).