-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arrow function are not allowed outside filters #3192
Comments
The limitations you list are on purpose to limit usage of arrow functions to simple use cases. |
Closed
To make this work this one line: https://github.com/twigphp/Twig/blob/3.x/src/ExpressionParser.php#L483 from: foreach ($this->parseArguments() as $n) { to: foreach ($this->parseArguments(false, false, true) as $n) { then closures all work in the context we want, e.g.: {% set collection = collect(['a', 'b', 'c']) %}
{% set contains = collection.contains((value, key) => value == 'a') %} with a nice, clean, normal syntax. I'd love to see this happen, too. |
See #4378 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Arrow functions currently can only be used in a filter as per ExpressionParser.
This prevents multiple functionalities such as
The text was updated successfully, but these errors were encountered: