From 4bd1335e069c8ba4a36794e039bab9d464e849a7 Mon Sep 17 00:00:00 2001 From: david_smith Date: Mon, 14 Oct 2024 12:15:16 -0400 Subject: [PATCH] Add isset() condition to coerce. --- src/DataModelHelper.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DataModelHelper.php b/src/DataModelHelper.php index bfd707a..f3b36fc 100644 --- a/src/DataModelHelper.php +++ b/src/DataModelHelper.php @@ -55,7 +55,7 @@ trait DataModelHelper public static function mapOf(mixed $value, array $context, ?ReflectionAttribute $Attribute, ReflectionProperty $Property) { $args = $Attribute?->getArguments(); - $value = isset($args[0]['coerce']) ? [$value] : $value; + $value = isset($args[0]['coerce']) && !isset($value[0]) ? [$value] : $value; if (isset($Attribute?->getArguments()[0]['using'])) { return ($Attribute?->getArguments()[0]['using'])($value);