From 40b5046f43b3177d92178c7470533aaf7865ca38 Mon Sep 17 00:00:00 2001
From: Alex Pott <alex.a.pott@googlemail.com>
Date: Fri, 26 Apr 2024 09:21:18 +0100
Subject: [PATCH] Issue #3443486 by smustgrave: Remove deprecated code from
 lib/Batch and lib/Datetime

---
 core/lib/Drupal/Core/Batch/BatchStorage.php   | 43 +++----------------
 .../Drupal/Core/Datetime/Element/Datetime.php | 23 ----------
 2 files changed, 7 insertions(+), 59 deletions(-)

diff --git a/core/lib/Drupal/Core/Batch/BatchStorage.php b/core/lib/Drupal/Core/Batch/BatchStorage.php
index 48c30a809cb5..03a3394b78b7 100644
--- a/core/lib/Drupal/Core/Batch/BatchStorage.php
+++ b/core/lib/Drupal/Core/Batch/BatchStorage.php
@@ -15,32 +15,6 @@ class BatchStorage implements BatchStorageInterface {
    */
   const TABLE_NAME = 'batch';
 
-  /**
-   * The database connection.
-   *
-   * @var \Drupal\Core\Database\Connection
-   */
-  protected $connection;
-
-  /**
-   * The session.
-   *
-   * @var \Symfony\Component\HttpFoundation\Session\SessionInterface
-   */
-  protected $session;
-
-  /**
-   * The CSRF token generator.
-   *
-   * @var \Drupal\Core\Access\CsrfTokenGenerator
-   */
-  protected $csrfToken;
-
-  /**
-   * The time service.
-   */
-  protected readonly TimeInterface $time;
-
   /**
    * Constructs the database batch storage service.
    *
@@ -48,20 +22,17 @@ class BatchStorage implements BatchStorageInterface {
    *   The database connection.
    * @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
    *   The session.
-   * @param \Drupal\Core\Access\CsrfTokenGenerator $csrf_token
+   * @param \Drupal\Core\Access\CsrfTokenGenerator $csrfToken
    *   The CSRF token generator.
    * @param \Drupal\Component\Datetime\TimeInterface $time
    *   The time service.
    */
-  public function __construct(Connection $connection, SessionInterface $session, CsrfTokenGenerator $csrf_token, TimeInterface $time = NULL) {
-    $this->connection = $connection;
-    $this->session = $session;
-    $this->csrfToken = $csrf_token;
-    if (!$time) {
-      @trigger_error('Calling ' . __METHOD__ . '() without the $time argument is deprecated in drupal:10.3.0 and is removed from drupal:11.0.0. See https://www.drupal.org/node/3220378', E_USER_DEPRECATED);
-      $time = \Drupal::service('datetime.time');
-    }
-    $this->time = $time;
+  public function __construct(
+    protected Connection $connection,
+    protected SessionInterface $session,
+    protected CsrfTokenGenerator $csrfToken,
+    protected TimeInterface $time,
+  ) {
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Datetime/Element/Datetime.php b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
index 10e7ab765fae..c979d77ee966 100644
--- a/core/lib/Drupal/Core/Datetime/Element/Datetime.php
+++ b/core/lib/Drupal/Core/Datetime/Element/Datetime.php
@@ -375,29 +375,6 @@ public static function validateDatetime(&$element, FormStateInterface $form_stat
     }
   }
 
-  /**
-   * Creates an example for a date format.
-   *
-   * This is centralized for a consistent method of creating these examples.
-   *
-   * @param string $format
-   *   The date format.
-   *
-   * @return string
-   *
-   * @deprecated in drupal:10.2.0 and is removed from drupal:11.0.0.
-   *   There is no replacement.
-   *
-   * @see https://www.drupal.org/node/3385058
-   */
-  public static function formatExample($format) {
-    @trigger_error(__METHOD__ . ' is deprecated in drupal:10.2.0 and is removed from drupal:11.0.0. There is no replacement. See https://www.drupal.org/node/3385058', E_USER_DEPRECATED);
-    if (!static::$dateExample) {
-      static::$dateExample = new DrupalDateTime();
-    }
-    return static::$dateExample->format($format);
-  }
-
   /**
    * Retrieves the right format for an HTML5 date element.
    *
-- 
GitLab