diff --git a/reference_value_pair.module b/reference_value_pair.module
index dc6e44e..5f1133e 100644
--- a/reference_value_pair.module
+++ b/reference_value_pair.module
@@ -4,46 +4,24 @@
  * @file
  * Contains reference_value_pair.module..
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\reference_value_pair\Hook\ReferenceValuePairHooks;
 use Drupal\Core\Routing\RouteMatchInterface;
 
 /**
  * Implements hook_help().
  */
+#[LegacyHook]
 function reference_value_pair_help($route_name, RouteMatchInterface $route_match) {
-  switch ($route_name) {
-    // Main module help for the reference_value_pair module.
-    case 'help.page.reference_value_pair':
-      $build['title'] = [
-        '#type' => 'html_tag',
-        '#tag' => 'h3',
-        '#value' => t('About'),
-      ];
-      $build['content'] = [
-        '#type' => 'html_tag',
-        '#tag' => 'p',
-        '#value' => t('Defines a field type to store a pair of an entity reference and a value.'),
-      ];
-      return $build;
-
-    default:
-  }
+  return \Drupal::service(ReferenceValuePairHooks::class)->help($route_name, $route_match);
 }
 
 /**
  * Implements hook_theme().
  */
+#[LegacyHook]
 function reference_value_pair_theme() {
-  return [
-    'reference_value_pair_formatter' => [
-      'variables' => [
-        'item' => NULL,
-        'entity' => NULL,
-        'url' => NULL,
-        'element' => [],
-      ],
-    ],
-  ];
+  return \Drupal::service(ReferenceValuePairHooks::class)->theme();
 }
 
 /**
@@ -65,16 +43,8 @@ function template_preprocess_reference_value_pair_formatter(&$variables) {
 /**
  * Implements hook_theme_suggestions_HOOK().
  */
-function reference_value_pair_theme_suggestions_reference_value_pair_formatter(array $variables) {
-  $suggestions = [];
-  $element = $variables['element'];
-  $prefix = $variables['theme_hook_original'] . '__';
-
-  $suggestions[] = $prefix . $element['#field_type'];
-  $suggestions[] = $prefix . $element['#field_name'];
-  $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#bundle'];
-  $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#field_name'];
-  $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#field_name'] . '__' . $element['#bundle'];
-
-  return $suggestions;
+#[LegacyHook]
+function reference_value_pair_theme_suggestions_reference_value_pair_formatter(array $variables)
+{
+    return \Drupal::service(ReferenceValuePairHooks::class)->themeSuggestionsReferenceValuePairFormatter($variables);
 }
diff --git a/reference_value_pair.services.yml b/reference_value_pair.services.yml
new file mode 100644
index 0000000..67085e4
--- /dev/null
+++ b/reference_value_pair.services.yml
@@ -0,0 +1,9 @@
+
+services:
+  Drupal\reference_value_pair\Hook\ReferenceValuePairHooks:
+    class: Drupal\reference_value_pair\Hook\ReferenceValuePairHooks
+    autowire: true
+
+  Drupal\reference_value_pair\Hook\ReferenceValuePairViewsHooks:
+    class: Drupal\reference_value_pair\Hook\ReferenceValuePairViewsHooks
+    autowire: true
diff --git a/reference_value_pair.views.inc b/reference_value_pair.views.inc
index f73a482..7141ae0 100644
--- a/reference_value_pair.views.inc
+++ b/reference_value_pair.views.inc
@@ -4,7 +4,9 @@
  * @file
  * Provide views data that isn't tied to any other module.
  */
-
+use Drupal\Core\Hook\Attribute\LegacyHook;
+use Drupal\reference_value_pair\Hook\ReferenceValuePairViewsHooks;
+use Drupal\Component\Utility\DeprecationHelper;
 use Drupal\field\FieldStorageConfigInterface;
 
 /**
@@ -14,74 +16,8 @@ use Drupal\field\FieldStorageConfigInterface;
  * relationship and a reverse relationship to entity_reference field type, which
  * is provided by core.
  */
-function reference_value_pair_field_views_data(FieldStorageConfigInterface $field_storage) {
-  $data = views_field_default_views_data($field_storage);
-
-  // The code below only deals with the Entity reference field type.
-  if ($field_storage->getType() != 'reference_value_pair') {
-    return $data;
-  }
-
-  // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
-  // We are assuming that we want to use the `entity_type.manager` service since no method was called here directly. Please confirm this is the case. See https://www.drupal.org/node/2549139 for more information.
-  $entity_manager = \Drupal::service('entity_type.manager');
-  $entity_type_id = $field_storage->getTargetEntityTypeId();
-  /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
-  $table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
-
-  foreach ($data as $table_name => $table_data) {
-    // Add a relationship to the target entity type.
-    $target_entity_type_id = $field_storage->getSetting('target_type');
-    $target_entity_type = $entity_manager->getDefinition($target_entity_type_id);
-    $entity_type_id = $field_storage->getTargetEntityTypeId();
-    $entity_type = $entity_manager->getDefinition($entity_type_id);
-    $target_base_table = $target_entity_type->getDataTable() ?: $target_entity_type->getBaseTable();
-    $field_name = $field_storage->getName();
-
-    // Provide a relationship for the entity type with the entity reference
-    // field.
-    $args = [
-      '@label' => $target_entity_type->getLabel(),
-      '@field_name' => $field_name,
-    ];
-    $data[$table_name][$field_name]['relationship'] = [
-      'title' => t('@label referenced from @field_name', $args),
-      'label' => t('@field_name: @label', $args),
-      'group' => $entity_type->getLabel(),
-      'help' => t('Appears in: @bundles.', ['@bundles' => implode(', ', $field_storage->getBundles())]),
-      'id' => 'standard',
-      'base' => $target_base_table,
-      'entity type' => $target_entity_type_id,
-      'base field' => $target_entity_type->getKey('id'),
-      'relationship field' => $field_name . '_target_id',
-    ];
-
-    // Provide a reverse relationship for the entity type that is referenced by
-    // the field.
-    $args['@entity'] = $entity_type->getLabel();
-    $args['@label'] = $target_entity_type->getSingularLabel();
-    $pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_name;
-    $data[$target_base_table][$pseudo_field_name]['relationship'] = [
-      'title' => t('@entity using @field_name', $args),
-      'label' => t('@field_name', ['@field_name' => $field_name]),
-      'group' => $target_entity_type->getLabel(),
-      'help' => t('Relate each @entity with a @field_name set to the @label.', $args),
-      'id' => 'entity_reverse',
-      'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
-      'entity_type' => $entity_type_id,
-      'base field' => $entity_type->getKey('id'),
-      'field_name' => $field_name,
-      'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
-      'field field' => $field_name . '_target_id',
-      'join_extra' => [
-        [
-          'field' => 'deleted',
-          'value' => 0,
-          'numeric' => TRUE,
-        ],
-      ],
-    ];
-  }
-
-  return $data;
+#[LegacyHook]
+function reference_value_pair_field_views_data(FieldStorageConfigInterface $field_storage)
+{
+    return \Drupal::service(ReferenceValuePairViewsHooks::class)->fieldViewsData($field_storage);
 }
diff --git a/src/Hook/ReferenceValuePairHooks.php b/src/Hook/ReferenceValuePairHooks.php
new file mode 100644
index 0000000..799ff14
--- /dev/null
+++ b/src/Hook/ReferenceValuePairHooks.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Drupal\reference_value_pair\Hook;
+
+use Drupal\Core\Routing\RouteMatchInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for reference_value_pair.
+ */
+class ReferenceValuePairHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_help().
+     */
+    #[Hook('help')]
+    public function help($route_name, \Drupal\Core\Routing\RouteMatchInterface $route_match)
+    {
+        switch ($route_name) {
+            // Main module help for the reference_value_pair module.
+            case 'help.page.reference_value_pair':
+                $build['title'] = [
+                    '#type' => 'html_tag',
+                    '#tag' => 'h3',
+                    '#value' => $this->t('About'),
+                ];
+                $build['content'] = [
+                    '#type' => 'html_tag',
+                    '#tag' => 'p',
+                    '#value' => $this->t('Defines a field type to store a pair of an entity reference and a value.'),
+                ];
+                return $build;
+            default:
+        }
+    }
+    /**
+     * Implements hook_theme().
+     */
+    #[Hook('theme')]
+    public static function theme()
+    {
+        return [
+            'reference_value_pair_formatter' => [
+                'variables' => [
+                    'item' => NULL,
+                    'entity' => NULL,
+                    'url' => NULL,
+                    'element' => [
+                    ],
+                ],
+            ],
+        ];
+    }
+    /**
+     * Implements hook_theme_suggestions_HOOK().
+     */
+    #[Hook('theme_suggestions_reference_value_pair_formatter')]
+    public static function themeSuggestionsReferenceValuePairFormatter(array $variables)
+    {
+        $suggestions = [
+        ];
+        $element = $variables['element'];
+        $prefix = $variables['theme_hook_original'] . '__';
+        $suggestions[] = $prefix . $element['#field_type'];
+        $suggestions[] = $prefix . $element['#field_name'];
+        $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#bundle'];
+        $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#field_name'];
+        $suggestions[] = $prefix . $element['#entity_type'] . '__' . $element['#field_name'] . '__' . $element['#bundle'];
+        return $suggestions;
+    }
+}
diff --git a/src/Hook/ReferenceValuePairViewsHooks.php b/src/Hook/ReferenceValuePairViewsHooks.php
new file mode 100644
index 0000000..ca3cd61
--- /dev/null
+++ b/src/Hook/ReferenceValuePairViewsHooks.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Drupal\reference_value_pair\Hook;
+
+use Drupal\Component\Utility\DeprecationHelper;
+use Drupal\field\FieldStorageConfigInterface;
+use Drupal\Core\Hook\Attribute\Hook;
+use Drupal\Core\StringTranslation\StringTranslationTrait;
+/**
+ * Hook implementations for reference_value_pair.
+ */
+class ReferenceValuePairViewsHooks
+{
+    use StringTranslationTrait;
+    /**
+     * Implements hook_field_views_data().
+     *
+     * The function implements the hook in behalf of 'core' because it adds a
+     * relationship and a reverse relationship to entity_reference field type, which
+     * is provided by core.
+     */
+    #[Hook('field_views_data')]
+    public function fieldViewsData(\Drupal\field\FieldStorageConfigInterface $field_storage)
+    {
+        $data = \Drupal\Component\Utility\DeprecationHelper::backwardsCompatibleCall(\Drupal::VERSION, '11.2.0', fn() => \Drupal::service('views.field_data_provider')->defaultFieldImplementation($field_storage), fn() => views_field_default_views_data($field_storage));
+        // The code below only deals with the Entity reference field type.
+        if ($field_storage->getType() != 'reference_value_pair') {
+            return $data;
+        }
+        // TODO: Drupal Rector Notice: Please delete the following comment after you've made any necessary changes.
+        // We are assuming that we want to use the `entity_type.manager` service since no method was called here directly. Please confirm this is the case. See https://www.drupal.org/node/2549139 for more information.
+        $entity_manager = \Drupal::service('entity_type.manager');
+        $entity_type_id = $field_storage->getTargetEntityTypeId();
+        /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */
+        $table_mapping = $entity_manager->getStorage($entity_type_id)->getTableMapping();
+        foreach ($data as $table_name => $table_data) {
+            // Add a relationship to the target entity type.
+            $target_entity_type_id = $field_storage->getSetting('target_type');
+            $target_entity_type = $entity_manager->getDefinition($target_entity_type_id);
+            $entity_type_id = $field_storage->getTargetEntityTypeId();
+            $entity_type = $entity_manager->getDefinition($entity_type_id);
+            $target_base_table = $target_entity_type->getDataTable() ?: $target_entity_type->getBaseTable();
+            $field_name = $field_storage->getName();
+            // Provide a relationship for the entity type with the entity reference
+            // field.
+            $args = [
+                '@label' => $target_entity_type->getLabel(),
+                '@field_name' => $field_name,
+            ];
+            $data[$table_name][$field_name]['relationship'] = [
+                'title' => $this->t('@label referenced from @field_name', $args),
+                'label' => $this->t('@field_name: @label', $args),
+                'group' => $entity_type->getLabel(),
+                'help' => $this->t('Appears in: @bundles.', [
+                    '@bundles' => implode(', ', $field_storage->getBundles()),
+                ]),
+                'id' => 'standard',
+                'base' => $target_base_table,
+                'entity type' => $target_entity_type_id,
+                'base field' => $target_entity_type->getKey('id'),
+                'relationship field' => $field_name . '_target_id',
+            ];
+            // Provide a reverse relationship for the entity type that is referenced by
+            // the field.
+            $args['@entity'] = $entity_type->getLabel();
+            $args['@label'] = $target_entity_type->getSingularLabel();
+            $pseudo_field_name = 'reverse__' . $entity_type_id . '__' . $field_name;
+            $data[$target_base_table][$pseudo_field_name]['relationship'] = [
+                'title' => $this->t('@entity using @field_name', $args),
+                'label' => $this->t('@field_name', [
+                    '@field_name' => $field_name,
+                ]),
+                'group' => $target_entity_type->getLabel(),
+                'help' => $this->t('Relate each @entity with a @field_name set to the @label.', $args),
+                'id' => 'entity_reverse',
+                'base' => $entity_type->getDataTable() ?: $entity_type->getBaseTable(),
+                'entity_type' => $entity_type_id,
+                'base field' => $entity_type->getKey('id'),
+                'field_name' => $field_name,
+                'field table' => $table_mapping->getDedicatedDataTableName($field_storage),
+                'field field' => $field_name . '_target_id',
+                'join_extra' => [
+                    [
+                        'field' => 'deleted',
+                        'value' => 0,
+                        'numeric' => TRUE,
+                    ],
+                ],
+            ];
+        }
+        return $data;
+    }
+}
diff --git a/src/Plugin/Field/FieldType/ReferenceValuePair.php b/src/Plugin/Field/FieldType/ReferenceValuePair.php
index c4fb184..8382a65 100755
--- a/src/Plugin/Field/FieldType/ReferenceValuePair.php
+++ b/src/Plugin/Field/FieldType/ReferenceValuePair.php
@@ -470,21 +470,21 @@ class ReferenceValuePair extends EntityReferenceItem {
   /**
    * {@inheritdoc}
    */
-  public function getPossibleValues(AccountInterface $account = NULL) {
+  public function getPossibleValues(?AccountInterface $account = NULL) {
     return $this->getSettableValues($account);
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getPossibleOptions(AccountInterface $account = NULL) {
+  public function getPossibleOptions(?AccountInterface $account = NULL) {
     return $this->getSettableOptions($account);
   }
 
   /**
    * {@inheritdoc}
    */
-  public function getSettableValues(AccountInterface $account = NULL) {
+  public function getSettableValues(?AccountInterface $account = NULL) {
     // Flatten options first, because "settable options" may contain group
     // arrays.
     $flatten_options = OptGroup::flattenOptions($this->getSettableOptions($account));
@@ -494,7 +494,7 @@ class ReferenceValuePair extends EntityReferenceItem {
   /**
    * {@inheritdoc}
    */
-  public function getSettableOptions(AccountInterface $account = NULL) {
+  public function getSettableOptions(?AccountInterface $account = NULL) {
     $field_definition = $this->getFieldDefinition();
     if (!$options = \Drupal::service('plugin.manager.entity_reference_selection')->getSelectionHandler($field_definition, $this->getEntity())->getReferenceableEntities()) {
       return [];
