From edd13c4fe199118b7cebe07856a52a1e75e1e977 Mon Sep 17 00:00:00 2001 From: Pedro Cambra <pedro@cambrico.net> Date: Mon, 21 Apr 2025 11:26:30 +0200 Subject: [PATCH] Issue #3520284: Implicitly marking parameter $user as nullable is deprecated, the explicit nullable type must be used instead --- src/Form/LikeForm.php | 2 +- src/LikeHelper.php | 6 +++--- src/LikeHelperInterface.php | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Form/LikeForm.php b/src/Form/LikeForm.php index 529c28b..76a63d5 100644 --- a/src/Form/LikeForm.php +++ b/src/Form/LikeForm.php @@ -62,7 +62,7 @@ class LikeForm extends FormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, FieldItemInterface $item = NULL, array $settings = []) { + public function buildForm(array $form, FormStateInterface $form_state, ?FieldItemInterface $item = NULL, array $settings = []) { $entity = $item->getEntity(); $form['#item'] = $item; $form['#theme'] = 'like_form'; diff --git a/src/LikeHelper.php b/src/LikeHelper.php index fd56daf..c8c2043 100644 --- a/src/LikeHelper.php +++ b/src/LikeHelper.php @@ -77,7 +77,7 @@ class LikeHelper implements LikeHelperInterface { /** * {@inheritdoc} */ - public function like(EntityInterface $entity, AccountInterface $user = NULL) { + public function like(EntityInterface $entity, ?AccountInterface $user = NULL) { if (empty($user)) { $user = $this->currentUser; } @@ -123,7 +123,7 @@ class LikeHelper implements LikeHelperInterface { /** * {@inheritdoc} */ - public function unlike(EntityInterface $entity, AccountInterface $user = NULL) { + public function unlike(EntityInterface $entity, ?AccountInterface $user = NULL) { if (empty($user)) { $user = $this->currentUser; } @@ -177,7 +177,7 @@ class LikeHelper implements LikeHelperInterface { /** * {@inheritdoc} */ - public function userHasLiked(EntityInterface $entity, AccountInterface $user = NULL):bool { + public function userHasLiked(EntityInterface $entity, ?AccountInterface $user = NULL):bool { if (empty($user)) { $user = $this->currentUser; } diff --git a/src/LikeHelperInterface.php b/src/LikeHelperInterface.php index 3315c0d..5bc02e5 100644 --- a/src/LikeHelperInterface.php +++ b/src/LikeHelperInterface.php @@ -22,7 +22,7 @@ interface LikeHelperInterface { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * @throws \Drupal\Core\Entity\EntityStorageException */ - public function like(EntityInterface $entity, AccountInterface $user = NULL); + public function like(EntityInterface $entity, ?AccountInterface $user = NULL); /** * Undoes a like. @@ -36,7 +36,7 @@ interface LikeHelperInterface { * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException * @throws \Drupal\Core\Entity\EntityStorageException */ - public function unlike(EntityInterface $entity, AccountInterface $user = NULL); + public function unlike(EntityInterface $entity, ?AccountInterface $user = NULL); /** * Checks whether a user has liked an entity. @@ -52,7 +52,7 @@ interface LikeHelperInterface { * @throws \Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException * @throws \Drupal\Component\Plugin\Exception\PluginNotFoundException */ - public function userHasLiked(EntityInterface $entity, AccountInterface $user = NULL):bool; + public function userHasLiked(EntityInterface $entity, ?AccountInterface $user = NULL):bool; /** * Get num of likes. -- GitLab