我有这段代码应该计算从对象中检索到的 for 循环中的项目。此代码在 symfony 5.0 项目上运行,带有 php 7.2.5 和 twig-bundle 5.0
{% set sent_mails = 0 %}
{% for email in emails if email.status == 1 %}
{% set sent_mails = (sent_mails + 1) %}
{% endfor %}
{{ sent_mails }}
它给出了以下错误:
当我使用 php 7.1.3 和 twig-bundle 4.2 在 Symfony 4.2 上运行相同的代码时,一切正常,没有错误。
我没有正确使用的 twig-bundle 代码语法是否有任何更改或我缺少什么?