diff --git a/src/support/src/DataObject.php b/src/support/src/DataObject.php index a018423e0..03f6df995 100644 --- a/src/support/src/DataObject.php +++ b/src/support/src/DataObject.php @@ -5,6 +5,7 @@ namespace Hypervel\Support; use ArrayAccess; +use BackedEnum; use Carbon\Carbon as BaseCarbon; use Carbon\CarbonInterface; use DateTime; @@ -289,9 +290,9 @@ protected static function resolveDependenciesMap(string $class, array &$visited $dataKey = static::isAutoCasting() ? static::convertPropertyToDataKey($property->getName()) : $property->getName(); - if (enum_exists($typeName)) { + if (enum_exists($typeName) && is_subclass_of($typeName, BackedEnum::class, true)) { $result[$dataKey] = [ - 'handler' => [$typeName, 'from'], + 'handler' => fn ($value) => $value instanceof $typeName ? $value : $typeName::from($value), 'nullable' => $allowsNull, 'children' => [], ];