mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-25 12:46:26 +00:00
54eff0d96ea6e4f51bccb7cf3dff2f0cd169a9a2
This PR was squashed before being merged into the 1.x branch.
Discussion
----------
In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
If a template accidentally performs `|filter(...)` on a variable that isn't traversable (e.g. `null`), the calling code will encouter the raw `TypeError` that results from Twig trying to construct an `IteratorIterator` on that variable. This means that context information (e.g., in which exact template the error occurred, and on which line) is discarded, which makes it very difficult to debug your templates.
This commit adds code to throw a `RuntimeError` if Twig encounters a situation where there's no valid way to filter an array.
Commits
-------
567b1e2a In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError
bug #3341 In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError (thijzert)
bug #3341 In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError (thijzert)
Twig, the flexible, fast, and secure template language for PHP
==============================================================
Twig is a template language for PHP, released under the new BSD license (code
and documentation).
Twig uses a syntax similar to the Django and Jinja template languages which
inspired the Twig runtime environment.
Sponsors
--------
.. raw:: html
<a href="https://blackfire.io/docs/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%