diff --git a/src/Form/LikeForm.php b/src/Form/LikeForm.php index 529c28b10915d38fc335df38ae174a6c3b9aaf9c..76a63d554f5c0d199b38b2913aa06881f547e0bf 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 fd56daf2e3d34117ad36ee70a288963d88a21145..c8c2043c2bdfb6d297c4cad7f0a6317713302779 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 3315c0d0620d955ce162c79071c78c920de7772d..5bc02e504b55de5ee5a0db284bdc2a89b100c62f 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.