Twig
Twig copied to clipboard
Introduce a CorrectnessNodeVisitor to validate that templates are semantically correct
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:
Parser::filterBodyNodes(): This method is a mix of ensuring the correctness of a template, but it also changes the body node of a child template (something that is always needed and not part of the correctness checks)ExtendsTokenParser: It checks that anextendtag is not embedded into a block or a macro. Theextendtag is not the only one that must be at the root of a template
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.
@fabpot what is the state of this PR ? Do you plan to fix it or to abandon it ?
@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).