private function setPropertyValuesToObject(Request $request, $object, array $fields): void
    {
        $objectClass = get_class($object);

        foreach ($fields as $propertyName => $attributeName) {
            $value = $request->attributes->get($attributeName);
            $propertyTypes = $this->propertyTypeExtractor->getTypes($objectClass, $propertyName);
            $propertyType = null;

            if ($propertyTypes) {
                $propertyType = array_pop($propertyTypes);
            }

            if (!$value) {
                // The value is empty. Throw exception if value cannot be nullable.
                if ($propertyType && !$propertyType->isNullable()) {
                    throw new MissingAttributeException(sprintf(
                        'Missing the attribute with name "%s" in request.',
                        $attributeName
                    ));
                }

                // We cannot get the type of property or property can be nullable.
                continue;
            }

            if ($propertyType->getBuiltinType() === Type::BUILTIN_TYPE_OBJECT) {
                // The property should be an object. Try denormalize.
                $value = $this->denormalizer->denormalize($value, $propertyType->getClassName());
            }

            $refProperty = new \ReflectionProperty($object, $propertyName);
            $refProperty->setAccessible(true);
            $refProperty->setValue($object, $value);
        }
    }