diff --git a/src/Services/LogSystem/TimeTravel.php b/src/Services/LogSystem/TimeTravel.php index cb612907..bffdb038 100644 --- a/src/Services/LogSystem/TimeTravel.php +++ b/src/Services/LogSystem/TimeTravel.php @@ -244,6 +244,15 @@ class TimeTravel $reflection = new ReflectionClass($element::class); $property = $reflection->getProperty($field); + //Check if the property is an BackedEnum, then convert the int or float value to an enum instance + if ((is_string($new_value) || is_int($new_value)) + && $property->getType() !== null + && is_a($property->getType()->getName(), \BackedEnum::class, true)) { + /** @phpstan-var class-string<\BackedEnum> $enum_class */ + $enum_class = $property->getType()->getName(); + $new_value = $enum_class::from($new_value); + } + $property->setValue($element, $new_value); } }