mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-06 23:48:50 +00:00
7f9714a13e26afa53c8e5ef0cd07f97adb230e17
This PR was squashed before being merged into the 3.x branch. Discussion ---------- 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 an `extend` tag is not embedded into a block or a macro. The `extend` tag 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. Commits -------c0504b90c5Handle single-node child template bodies in cleanupa69d3dc71eKeep captured block definitions supported16e5a937edClarify captured block deprecation wording8a0ae2204cSimplify correctness visitor checksffcae61b15Move extends validation into correctness visitord96eac3895Fix correctness visitor regressions89e8699a73Fix test assertions that did not verify the intended behavior4b2e651dd5Address review: fix block-nesting checks in CorrectnessNodeVisitorde7bbc7be9Move the extends-in-block and extends-in-macro errors into the CorrectnessNodeVisitorc12100525eIntroduce a CorrectnessNodeVisitor to validate that templates are semantically correct
…
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP.
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://docs.blackfire.io/introduction?utm_source=twig&utm_medium=github_readme&utm_campaign=logo">
<img src="https://static.blackfire.io/assets/intemporals/logo/png/blackfire-io_secondary_horizontal_transparent.png?1" width="255px" alt="Blackfire.io">
</a>
More Information
----------------
Read the `documentation`_ for more information.
.. _documentation: https://twig.symfony.com/documentation
Description
Languages
PHP
99.9%