Fabien Potencier 54eff0d96e bug #3341 In |filter(), |map(), and |reduce(), throw a RuntimeError instead of a TypeError (thijzert)
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
2020-08-23 16:40:19 +02:00
2020-08-23 13:58:27 +02:00
2019-11-11 17:50:21 +01:00
2020-08-23 14:19:17 +02:00
2019-10-17 09:29:33 +02:00
2019-08-08 18:07:23 +02:00
2020-05-21 11:01:36 +02:00
2020-08-23 14:20:00 +02:00
2020-08-23 13:59:06 +02:00
2020-06-22 09:21:52 +02:00
2020-02-11 17:31:46 +01:00
2020-08-23 12:46:19 +02:00
2019-06-28 17:37:46 +02:00

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
Languages
PHP 99.9%