This PR was merged into the 1.x branch.
Discussion
----------
Fix a PHP fatal error when calling a macro, imported in the template, in another macro
The current code iterates over all imported functions (traversing all the scopes). So, the macro was found at compilation time, but didn't work at runtime, leading to a PHP fatal error. Now, you get a proper exception at compilation time.
Commits
-------
ba9b9681 fixed a PHP fatal error when calling a macro, imported in the template, in another macro
This PR was merged into the 1.x branch.
Discussion
----------
Fix wrong error message on "import" and "from"
Commits
-------
118462c1 fixed wrong error message on "import" and "from"
This PR was merged into the 1.x branch.
Discussion
----------
Correct Twig_SimpleFilter, Twig_SimpleFunction, Twig_SimpleTest deprecation doc
Reverts https://github.com/twigphp/Twig/commit/3632a46e82fbb391b0fc72674bd8946e0b7c5bf7 for deprecated.rst
Commits
-------
65047482 Correct Twig_SimpleFilter/Twig_SimpleFunction/Twig_SimpleTest deprecation doc (Revert: moved to namespaced classes by default)
This PR was squashed before being merged into the 1.x branch (closes#3004).
Discussion
----------
Fix support for PHP 7.4
Commits
-------
f958bd1e fixed deprecation under PHP 7.4
1fb0f970 fixed PHP 7.4 support
7be8e944 added PHP 7.4 in Travis config
This PR was merged into the 1.x branch.
Discussion
----------
Fix support for IteratorAggregate in the filter filter
Commits
-------
084be27d fixed support for IteratorAggregate in the filter filter
This PR was squashed before being merged into the 1.x branch (closes#2996).
Discussion
----------
Add "filter", "map", and "reduce" filters
This PR adds support for 3 new filters: `filter`, `map`, and `reduce`. They take an arrow function as an argument (a PHP closure).
I have restricted the usage of arrow functions as much as possible as it makes no sense to support them everywhere. So, for now, they are only accepted as arguments to filters (using them as arguments to function is not supported but could be easily added if we have a use case).
The syntax is the following: `(x) => x + 3` where `(x)` is the list of arguments, `=>` starts the body, and the body is any Twig expression. Within the arrow function, the context is also available: `(x) => x + offset` works if `offset` is defined in the current context.
~~These new filters will allow us to deprecate the `if` support on the `for` tag, which does not work well with the `loop` variable:~~
```twig
{% set sizes = {xs: 34, s: 36, m: 38, l: 40, xl: 42} %}
{# before #}
{% for name, size in sizes if size < 38 %}
{{ name }} = {{ size }}
{% loop.last ? 'LAST' %} {# <--- works with this PR #}
{% endfor %}
{# after #}
{% for name, size in sizes|filter(size => size < 38) %}
{{ name }} = {{ size }}
{{ loop.last ? 'LAST' }}
{% endfor %}
```
This closes#2785
Commits
-------
5c15f897 added the key to the map and filter filters
13274bbf added support for iterators
175041e0 removed fn in front of arrow functions
dc277635 changed arrow syntax
b30bce11 added "filter", "map", and "reduce" filters
This PR was merged into the 1.x branch.
Discussion
----------
Fix partial output leak when a PHP fatal error occurs
closes#1962 (thank you @fluff for the "trick")
Commits
-------
6196fe5b fixed partial output leak when a PHP fatal error occurs
This PR was merged into the 1.x branch.
Discussion
----------
Add tests to avoid regressions (via Drupal)
Commits
-------
9c313e3c added Drupal in the CI process
This PR was merged into the 1.x branch.
Discussion
----------
Optimize context access on PHP 7.4
Commits
-------
5b5f5659 optimized context access on PHP 7.4
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2992).
Discussion
----------
add column filter to index
Commits
-------
e804338b add column filter to index
This PR was merged into the 1.x branch.
Discussion
----------
Fix regression in NodeTraverser
Commits
-------
e89800de fixed regression in NodeTraverser
This PR was merged into the 1.x branch.
Discussion
----------
Allow Twig\NodeVisitor\NodeVisitorInterface::leaveNode() to return "null" instead of "false" (same meaning)
Commits
-------
f297b52f allowed Twig\NodeVisitor\NodeVisitorInterface::leaveNode() to return "null" instead of "false" (same meaning)
This PR was submitted for the 2.x branch but it was merged into the 1.x branch instead (closes#2983).
Discussion
----------
Add Parser typehint
This makes it easier to work with.
Commits
-------
9ead7df1 Add Parser typehint