Validate the input of CoreExtension::map()

This commit is contained in:
Alexander M. Turek
2024-09-03 17:18:47 +02:00
parent 3349175e72
commit a035204afb
+4
View File
@@ -1833,6 +1833,10 @@ final class CoreExtension extends AbstractExtension
*/
public static function map(Environment $env, $array, $arrow)
{
if (!is_iterable($array)) {
throw new RuntimeError(\sprintf('The "map" filter expects a sequence/mapping or "Traversable", got "%s".', get_debug_type($array)));
}
self::checkArrowInSandbox($env, $arrow, 'map', 'filter');
$r = [];