Skip to content

Commit 8de6e80

Browse files
committed
fix: add ability to escape error, when serialized parameter is closure or callable function
1 parent 2d17302 commit 8de6e80

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/Instrumentation/Laravel/src/Watchers/RedisCommand/Serializer.php

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,17 @@ public static function serializeCommand(string $command, array $params): string
7070
}
7171

7272
// In some cases (for example when using LUA scripts) arrays are valid parameters
73-
$paramsToSerialize = array_map(function ($param) { return is_array($param) ? json_encode($param) : $param; }, $paramsToSerialize);
73+
// In additional cases, Closure are also valid parameters (Pipeline command)
74+
$paramsToSerialize = array_map(
75+
static function ($param) {
76+
return match (true) {
77+
is_array($param) => json_encode($param),
78+
is_callable($param) => 'Callable',
79+
default => $param,
80+
};
81+
},
82+
$paramsToSerialize
83+
);
7484

7585
return $command . ' ' . implode(' ', $paramsToSerialize);
7686
}

0 commit comments

Comments
 (0)