Add "some" and "every" filters
This PR adds 2 new tests inspired from Javascript's functions: some and every.
Usage :
Value {{ ([1, 2, 3] has some v => v == 2) ? 'found' : 'not found' }}
Key {{ ([1, 2, 3] has some (v, k) => k == 2) ? 'found' : 'not found' }}
Every values {{ ([1, 2, 3] has every v => 42 > v) ? 'match' : 'do not match' }}
Every keys {{ ([1, 2, 3] has every (v, k) => 42 > k) ? 'match' : 'do not match' }}
Something returning a boolean looks like a use case for a Twig test rather than a Twig filter.
You're right. I changed these filter to binary expression (like starts with). The \Twig\ExpressionParser::parseExpression had to be updated to allow arrow functions in right operator.
Thank you @Jean-Beru.
This is still missing in the docs.
@jdreesen Would you like to work on some docs? Or maybe @Jean-Beru?
I forgot it, my bad. This is done in https://github.com/twigphp/Twig/pull/3797.