From d4e8a5659f15f52e8ec1011927a2debf7f24b84b Mon Sep 17 00:00:00 2001 From: Benjamin Eberlei Date: Tue, 21 Oct 2025 11:56:15 +0200 Subject: [PATCH] Replace array_map with foreach improves performance. --- src/JWadhams/JsonLogic.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/JWadhams/JsonLogic.php b/src/JWadhams/JsonLogic.php index 8e0227d..16a3421 100644 --- a/src/JWadhams/JsonLogic.php +++ b/src/JWadhams/JsonLogic.php @@ -50,9 +50,11 @@ public static function apply($logic = [], $data = []) if (! self::is_logic($logic)) { if (is_array($logic)) { //Could be an array of logic statements. Only one way to find out. - return array_map(function ($l) use ($data) { - return self::apply($l, $data); - }, $logic); + $values = []; + foreach ($logic as $key => $value) { + $values[$key] = self::apply($value, $data); + } + return $values; } else { return $logic; }