$value){ if(is_string($value)){ try{ $type = (new \ReflectionProperty($object, $property))->getType(); if($type instanceof \ReflectionNamedType){ $typeName = $type->getName(); if($typeName != 'string' && is_a($typeName, 'BackedEnum', true)){ $object->$property = $typeName::from($value); } else{ $object->$property = $value; } } } catch(\Exception){ $object->$property = $value; } } else{ $object->$property = $value; } } return $object; } /** * Return an object based on a database row result. This is a fallback object filler for when the parent class hasn't defined their own. */ public static function FromRow(\stdClass $row): static{ return self::FillObject(new static(), $row); } }