private function buildFields(
        ResourceContentType $contentType,
        array $fields,
        ResourceClass $previous = null
    ): array {
        if ($previous) {
            $fields = $this->mergePreviousFields($fields, $previous);
        }

        foreach ($fields as $name => $data) {
            $field = $contentType->getField($name);

            // If field is empty, it means that the data currently available
            // for the content type is not correct.
            // Instead of failing and causing a type error, we fallback on a simple
            // field, and leave the handling of those edge cases to the user.
            if (!$field) {
                @\trigger_error(\sprintf(
                    'Entry of content type "%s" ("%s") being built contains field "%s" which is not present in the content type definition.'
                    .' Please check your cache for stale content type definitions.',
                    $contentType->getName(),
                    $contentType->getId(),
                    $name
                ), \E_USER_WARNING);
                $field = $contentType->addUnknownField($name);
            }

            foreach ($data as $locale => $value) {
                $fields[$name][$locale] = $this->formatValue(
                    $field->getType(),
                    $value,
                    $field->getItemsType()
                );
            }
        }

        return $fields;
    }
private function buildFields(
        ResourceContentType $contentType,
        array $fields,
        ResourceClass $previous = null
    ): array {
        if ($previous) {
            $fields = $this->mergePreviousFields($fields, $previous);
        }

        foreach ($fields as $name => $data) {
            $field = $contentType->getField($name);

            // If field is empty, it means that the data currently available
            // for the content type is not correct.
            // Instead of failing and causing a type error, we fallback on a simple
            // field, and leave the handling of those edge cases to the user.
            if (!$field) {
                @\trigger_error(\sprintf(
                    'Entry of content type "%s" ("%s") being built contains field "%s" which is not present in the content type definition.'
                    .' Please check your cache for stale content type definitions.',
                    $contentType->getName(),
                    $contentType->getId(),
                    $name
                ), \E_USER_WARNING);
                $field = $contentType->addUnknownField($name);
            }

            foreach ($data as $locale => $value) {
                $fields[$name][$locale] = $this->formatValue(
                    $field->getType(),
                    $value,
                    $field->getItemsType()
                );
            }
        }

        return $fields;
    }
@param ResourceContentType $contentType
@param array               $fields
@param ResourceClass|null  $previous

@return array