From 276e51fc92ba8159b5e0783d07f671dfd75956b6 Mon Sep 17 00:00:00 2001 From: Pedro Cambra <31853-pcambra@users.noreply.drupalcode.org> Date: Wed, 19 Feb 2025 12:36:36 +0000 Subject: [PATCH] Issue #3500327 by pcambra, klausi: Nullable types must be explicit --- src/Form/RevisionRevertForm.php | 6 +++++- src/QueryAccess/EventOnlyQueryAccessHandler.php | 2 +- src/QueryAccess/QueryAccessHandlerBase.php | 2 +- src/QueryAccess/QueryAccessHandlerInterface.php | 4 ++-- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/src/Form/RevisionRevertForm.php b/src/Form/RevisionRevertForm.php index f1e5707..fc7ee77 100644 --- a/src/Form/RevisionRevertForm.php +++ b/src/Form/RevisionRevertForm.php @@ -3,6 +3,7 @@ namespace Drupal\entity\Form; use Drupal\Core\Datetime\DateFormatterInterface; +use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; use Drupal\Core\Entity\RevisionableInterface; use Drupal\Core\Form\ConfirmFormBase; @@ -11,6 +12,9 @@ use Drupal\Core\Entity\RevisionLogInterface; use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\HttpFoundation\Request; +/** + * Form to confirm reverting an entity revision. + */ class RevisionRevertForm extends ConfirmFormBase { /** @@ -101,7 +105,7 @@ class RevisionRevertForm extends ConfirmFormBase { /** * {@inheritdoc} */ - public function buildForm(array $form, FormStateInterface $form_state, $_entity_revision = NULL, Request $request = NULL) { + public function buildForm(array $form, FormStateInterface $form_state, EntityInterface|RevisionableInterface|RevisionLogInterface|NULL $_entity_revision = NULL, ?Request $request = NULL) { $this->revision = $_entity_revision; $form = parent::buildForm($form, $form_state); diff --git a/src/QueryAccess/EventOnlyQueryAccessHandler.php b/src/QueryAccess/EventOnlyQueryAccessHandler.php index 1f65745..c58ec24 100644 --- a/src/QueryAccess/EventOnlyQueryAccessHandler.php +++ b/src/QueryAccess/EventOnlyQueryAccessHandler.php @@ -68,7 +68,7 @@ final class EventOnlyQueryAccessHandler implements EntityHandlerInterface, Query /** * {@inheritdoc} */ - public function getConditions($operation, AccountInterface $account = NULL) { + public function getConditions($operation, ?AccountInterface $account = NULL) { $account = $account ?: $this->currentUser; $entity_type_id = $this->entityType->id(); $conditions = new ConditionGroup('OR'); diff --git a/src/QueryAccess/QueryAccessHandlerBase.php b/src/QueryAccess/QueryAccessHandlerBase.php index 8df9c47..2285f33 100644 --- a/src/QueryAccess/QueryAccessHandlerBase.php +++ b/src/QueryAccess/QueryAccessHandlerBase.php @@ -81,7 +81,7 @@ abstract class QueryAccessHandlerBase implements EntityHandlerInterface, QueryAc /** * {@inheritdoc} */ - public function getConditions($operation, AccountInterface $account = NULL) { + public function getConditions($operation, ?AccountInterface $account = NULL) { $account = $account ?: $this->currentUser; $entity_type_id = $this->entityType->id(); $conditions = $this->buildConditions($operation, $account); diff --git a/src/QueryAccess/QueryAccessHandlerInterface.php b/src/QueryAccess/QueryAccessHandlerInterface.php index 36e8324..ea7e1dc 100644 --- a/src/QueryAccess/QueryAccessHandlerInterface.php +++ b/src/QueryAccess/QueryAccessHandlerInterface.php @@ -30,13 +30,13 @@ interface QueryAccessHandlerInterface { * @param string $operation * The access operation. Usually one of "view", "update", "duplicate", * or "delete". - * @param \Drupal\Core\Session\AccountInterface $account + * @param \Drupal\Core\Session\AccountInterface|null $account * The user for which to restrict access, or NULL * to assume the current user. Defaults to NULL. * * @return \Drupal\entity\QueryAccess\ConditionGroup * The conditions. */ - public function getConditions($operation, AccountInterface $account = NULL); + public function getConditions($operation, ?AccountInterface $account = NULL); } -- GitLab