mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-05 23:17:26 +00:00
Throw exception in case non-Traversable data is passed to "filter" filter
This commit is contained in:
committed by
Fabien Potencier
parent
fa94cc4934
commit
5311963eb3
@@ -1695,6 +1695,10 @@ function twig_array_batch($items, $size, $fill = null, $preserveKeys = true)
|
||||
|
||||
function twig_array_filter($array, $arrow)
|
||||
{
|
||||
if (!twig_test_iterable($array)) {
|
||||
throw new RuntimeError(sprintf('The "filter" filter expects an array or "Traversable", got "%s".', \is_object($array) ? \get_class($array) : \gettype($array)));
|
||||
}
|
||||
|
||||
if (\is_array($array)) {
|
||||
if (\PHP_VERSION_ID >= 50600) {
|
||||
return array_filter($array, $arrow, \ARRAY_FILTER_USE_BOTH);
|
||||
|
||||
Reference in New Issue
Block a user