From a6ba33b2045eef77089b0257b17fe41b2f63e889 Mon Sep 17 00:00:00 2001
From: catch <catch@35733.no-reply.drupal.org>
Date: Wed, 28 Feb 2024 18:11:01 +0000
Subject: [PATCH] Issue #3424177 by longwave, andypost: Remove
 ContainerAwareInterface from DrupalKernelInterface

---
 core/lib/Drupal/Core/DrupalKernel.php         | 27 +++----------------
 .../lib/Drupal/Core/DrupalKernelInterface.php |  3 +--
 core/phpstan-baseline.neon                    |  8 ------
 3 files changed, 4 insertions(+), 34 deletions(-)

diff --git a/core/lib/Drupal/Core/DrupalKernel.php b/core/lib/Drupal/Core/DrupalKernel.php
index 6bd6cffb3135..f8bbaf8699b9 100644
--- a/core/lib/Drupal/Core/DrupalKernel.php
+++ b/core/lib/Drupal/Core/DrupalKernel.php
@@ -549,20 +549,6 @@ public function getContainer() {
     return $this->container;
   }
 
-  /**
-   * {@inheritdoc}
-   */
-  public function setContainer(ContainerInterface $container = NULL): void {
-    if (isset($this->container)) {
-      throw new \Exception('The container should not override an existing container.');
-    }
-    if ($this->booted) {
-      throw new \Exception('The container cannot be set after a booted kernel.');
-    }
-
-    $this->container = $container;
-  }
-
   /**
    * {@inheritdoc}
    */
@@ -940,22 +926,15 @@ protected function initializeContainer() {
       $all_messages = $this->container->get('messenger')->all();
     }
 
-    // If we haven't booted yet but there is a container, then we're asked to
-    // boot the container injected via setContainer().
-    // @see \Drupal\KernelTests\KernelTestBase::setUp()
-    if (isset($this->container) && !$this->booted) {
-      $container = $this->container;
-    }
-
     // If the module list hasn't already been set in updateModules and we are
     // not forcing a rebuild, then try and load the container from the cache.
     if (empty($this->moduleList) && !$this->containerNeedsRebuild) {
       $container_definition = $this->getCachedContainerDefinition();
     }
 
-    // If there is no container and no cached container definition, build a new
-    // one from scratch.
-    if (!isset($container) && !isset($container_definition)) {
+    // If there is no cached container definition, build a new container from
+    // scratch.
+    if (!isset($container_definition)) {
       $container = $this->compileContainer();
 
       // Only dump the container if dumping is allowed. This is useful for
diff --git a/core/lib/Drupal/Core/DrupalKernelInterface.php b/core/lib/Drupal/Core/DrupalKernelInterface.php
index f42e8eec6fb3..dd7864cd7b45 100644
--- a/core/lib/Drupal/Core/DrupalKernelInterface.php
+++ b/core/lib/Drupal/Core/DrupalKernelInterface.php
@@ -2,7 +2,6 @@
 
 namespace Drupal\Core;
 
-use Symfony\Component\DependencyInjection\ContainerAwareInterface;
 use Symfony\Component\HttpKernel\HttpKernelInterface;
 use Symfony\Component\HttpFoundation\Request;
 
@@ -12,7 +11,7 @@
  * This interface extends Symfony's KernelInterface and adds methods for
  * responding to modules being enabled or disabled during its lifetime.
  */
-interface DrupalKernelInterface extends HttpKernelInterface, ContainerAwareInterface {
+interface DrupalKernelInterface extends HttpKernelInterface {
 
   /**
    * Event fired when the service container finished initializing in subrequest.
diff --git a/core/phpstan-baseline.neon b/core/phpstan-baseline.neon
index d968d46bc86c..ae8a75f01291 100644
--- a/core/phpstan-baseline.neon
+++ b/core/phpstan-baseline.neon
@@ -432,14 +432,6 @@ parameters:
 			count: 1
 			path: lib/Drupal/Core/DrupalKernel.php
 
-		-
-			message: """
-				#^Interface Drupal\\\\Core\\\\DrupalKernelInterface extends deprecated interface Symfony\\\\Component\\\\DependencyInjection\\\\ContainerAwareInterface\\:
-				since Symfony 6\\.4, use dependency injection instead$#
-			"""
-			count: 1
-			path: lib/Drupal/Core/DrupalKernelInterface.php
-
 		-
 			message: "#^Method Drupal\\\\Core\\\\Entity\\\\ContentEntityConfirmFormBase\\:\\:save\\(\\) should return int but return statement is missing\\.$#"
 			count: 1
-- 
GitLab