diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index 37880aa56323b4a58bc53f9af89ae566505c6b65..db70c7c6e684985829b48d1e94d1e79f892da3b1 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -158,7 +158,6 @@
   <rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis">
     <exclude-pattern>*/Functional/*</exclude-pattern>
     <exclude-pattern>*/FunctionalJavascript/*</exclude-pattern>
-    <exclude-pattern>*/core/tests/*</exclude-pattern>
     <exclude-pattern>*/core/profiles/*/tests/*</exclude-pattern>
     <!-- Do not run this sniff on API files or transliteration data. -->
     <exclude-pattern>*.api.php</exclude-pattern>
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php
index 238474e5ae7bf4368fe6d8e1c4008cf614058005..6a0026976a90a5385ff53f03824ffa185bb6e6f0 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/Ajax/MultiFormTest.php
@@ -91,7 +91,7 @@ public function testMultiForm(): void {
 
     for ($i = 0; $i < 2; $i++) {
       $forms = $page->findAll('xpath', $form_xpath);
-      foreach ($forms as $offset => $form) {
+      foreach ($forms as $form) {
         $button = $form->findButton('Add another item');
         $this->assertNotNull($button, 'Add Another Item button exists');
         $button->press();
diff --git a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
index 6237e447f4924c2470c44d53d85b0dbf96877cf4..bae02bf2b9055dd72051b5ec3762ed3b3fe1f40d 100644
--- a/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
+++ b/core/tests/Drupal/FunctionalJavascriptTests/WebDriverCurlService.php
@@ -136,7 +136,7 @@ public function execute($requestMethod, $url, $parameters = NULL, $extraOptions
         $info = curl_getinfo($curl);
         $info['request_method'] = $requestMethod;
 
-        if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && $extraOptions[CURLOPT_FAILONERROR] && CURLE_GOT_NOTHING !== ($errno = curl_errno($curl)) && $error = curl_error($curl)) {
+        if (array_key_exists(CURLOPT_FAILONERROR, $extraOptions) && $extraOptions[CURLOPT_FAILONERROR] && CURLE_GOT_NOTHING !== curl_errno($curl) && $error = curl_error($curl)) {
           curl_close($curl);
 
           throw WebDriverException::factory(WebDriverException::CURL_EXEC, sprintf("Curl error thrown for http %s to %s%s\n\n%s", $requestMethod, $url, $parameters && is_array($parameters) ? ' with params: ' . json_encode($parameters) : '', $error));
diff --git a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
index ef8ce03f1c11dc4b7304ccde100d69a422602ec0..80a04707573e725c7aa7f462e98e389b9a8a5c3c 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/ConnectionTest.php
@@ -128,7 +128,7 @@ public function testPerTablePrefixOption(): void {
     ];
     Database::addConnectionInfo('default', 'foo', $new_connection_info);
     $this->expectException(\AssertionError::class);
-    $foo_connection = Database::getConnection('foo', 'default');
+    Database::getConnection('foo', 'default');
   }
 
   /**
@@ -142,7 +142,7 @@ public function testPrefixArrayOption(): void {
     ];
     Database::addConnectionInfo('default', 'foo', $new_connection_info);
     $this->expectException(\AssertionError::class);
-    $foo_connection = Database::getConnection('foo', 'default');
+    Database::getConnection('foo', 'default');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
index 4a40641a92b2741ce1345050c8f33dcdfb60cd12..0c5da802929d0baef377c48ff8af50ceb906998e 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DeleteTruncateTest.php
@@ -77,6 +77,7 @@ public function testTruncateInTransaction(): void {
     $num_records_before = $this->connection->select('test')->countQuery()->execute()->fetchField();
     $this->assertGreaterThan(0, $num_records_before, 'The table is not empty.');
 
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
     $transaction = $this->connection->startTransaction('test_truncate_in_transaction');
     $this->connection->insert('test')
       ->fields([
@@ -98,6 +99,7 @@ public function testTruncateInTransaction(): void {
 
     // Close the transaction, and check that there are still no records in the
     // table.
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
     $transaction = NULL;
     $this->assertFalse($this->connection->inTransaction());
     $num_records_after = $this->connection->select('test')->countQuery()->execute()->fetchField();
@@ -111,6 +113,7 @@ public function testTruncateTransactionRollback(): void {
     $num_records_before = $this->connection->select('test')->countQuery()->execute()->fetchField();
     $this->assertGreaterThan(0, $num_records_before, 'The table is not empty.');
 
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
     $transaction = $this->connection->startTransaction('test_truncate_in_transaction');
     $this->connection->insert('test')
       ->fields([
diff --git a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
index 50a62374099c5e0ccadb2014badfcd1e720a09c8..da331170fadaa335df95b54cd0a295354622e206 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/DriverSpecificTransactionTestBase.php
@@ -239,6 +239,7 @@ public function testRollbackRootAfterSavepointRollback(): void {
    */
   public function testRollbackRootWithActiveSavepoint(): void {
     $transaction = $this->createRootTransaction();
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $savepoint = $this->createFirstSavepointTransaction();
 
     // Try to rollback root. Since a savepoint is active, this should fail.
@@ -278,6 +279,7 @@ public function testRollbackSavepoint(): void {
    * Tests savepoint transaction duplicated rollback.
    */
   public function testRollbackTwiceSameSavepoint(): void {
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $transaction = $this->createRootTransaction();
     $savepoint = $this->createFirstSavepointTransaction();
 
@@ -312,11 +314,13 @@ public function testRollbackTwiceSameSavepoint(): void {
    * Tests savepoint transaction rollback failure when later savepoints exist.
    */
   public function testRollbackSavepointWithLaterSavepoint(): void {
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $transaction = $this->createRootTransaction();
     $savepoint1 = $this->createFirstSavepointTransaction();
 
     // Starts another savepoint transaction. Corresponds to 'SAVEPOINT
     // savepoint_2' on the database.
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $savepoint2 = $this->connection->startTransaction();
     $this->assertTrue($this->connection->inTransaction());
     $this->assertSame(3, $this->connection->transactionManager()->stackDepth());
@@ -706,10 +710,12 @@ public function testReleaseIntermediateSavepoint(): void {
     $this->assertSame(3, $this->connection->transactionManager()->stackDepth());
     // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_3'
     // on the database.
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $savepoint3 = $this->connection->startTransaction();
     $this->assertSame(4, $this->connection->transactionManager()->stackDepth());
     // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_4'
     // on the database.
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $savepoint4 = $this->connection->startTransaction();
     $this->assertSame(5, $this->connection->transactionManager()->stackDepth());
 
@@ -736,6 +742,7 @@ public function testReleaseIntermediateSavepoint(): void {
    */
   public function testCommitWithActiveSavepoint(): void {
     $transaction = $this->createRootTransaction();
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     $savepoint1 = $this->createFirstSavepointTransaction('', FALSE);
 
     // Starts a savepoint transaction. Corresponds to 'SAVEPOINT savepoint_2'
@@ -774,7 +781,7 @@ public function testTransactionName(): void {
 
     $this->expectException(TransactionNameNonUniqueException::class);
     $this->expectExceptionMessage("savepoint_1 is already in use.");
-    $savepointFailure = $this->connection->startTransaction('savepoint_1');
+    $this->connection->startTransaction('savepoint_1');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
index 6a0f4355ca228ae327588f32bcbf50abaa7160fe..d21f512b542c47efe2a3b3d62d11012ff8271b3c 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/QueryTest.php
@@ -30,7 +30,7 @@ public function testArraySubstitution(): void {
    */
   public function testScalarSubstitution(): void {
     try {
-      $names = $this->connection->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [':ages[]' => 25])->fetchAll();
+      $this->connection->query('SELECT [name] FROM {test} WHERE [age] IN ( :ages[] ) ORDER BY [age]', [':ages[]' => 25])->fetchAll();
       $this->fail('Array placeholder with scalar argument should result in an exception.');
     }
     catch (\Exception $e) {
diff --git a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php
index e14f39cb30dac010ec71e0bc11328ef9327eb120..37a0bbf47089e97107aab6435798e99f1efe62b0 100644
--- a/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Database/StatementTest.php
@@ -186,9 +186,11 @@ public function testEmptyStatementRewind(): void {
 
     $count = 0;
 
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     foreach ($statement as $row) {
       $count++;
     }
+    // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis
     foreach ($statement as $row) {
       $count++;
     }
@@ -209,7 +211,7 @@ public function testStatementCountTwice(): void {
 
     $this->expectException(DatabaseExceptionWrapper::class);
     $this->expectExceptionMessage('Attempted rewinding a StatementInterface object when fetching has already started. Refactor your code to avoid rewinding statement objects.');
-    $rowCount = iterator_count($statement);
+    iterator_count($statement);
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php
index 8df18f1b4291e0d35c9b9117b9aae832f72a77e2..dc231832e2f2820af7f61f2e08aa8a0811b17369 100644
--- a/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Datetime/DatelistElementFormTest.php
@@ -124,7 +124,7 @@ public function testDatelistElement(): void {
   public function testDatelistElementUntrustedCallbacks() : void {
     $this->expectException(UntrustedCallbackException::class);
     $this->expectExceptionMessage(sprintf('Datelist element #date_date_callbacks callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/3217966', Variable::callableToString([$this, 'datelistDateCallback'])));
-    $form = \Drupal::formBuilder()->getForm($this, 'datelistDateCallback');
+    \Drupal::formBuilder()->getForm($this, 'datelistDateCallback');
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
index 491e37ae818d5e869fbeada09e28c9eea4e034df..a66df34d7bd3f5575e2ca8ed9128e731758d7644 100644
--- a/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Datetime/Element/TimezoneTest.php
@@ -342,7 +342,7 @@ public function assertDateTimezonePropertyProcessed(string $elementType): void {
 
     // Check the #date_timezone property on each processed test element.
     $wrongTimezones = [];
-    foreach ($form_state->getCompleteForm() as $elementName => $element) {
+    foreach ($form_state->getCompleteForm() as $element) {
       if (isset($element['#type']) && $element['#type'] === $this->elementType) {
         // Check the correct timezone is set on the value object.
         $actualTimezone = array_search($element['#date_timezone'], $this->timezones, TRUE);
diff --git a/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php b/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php
index 7601550d1d06c0feee1f0046df5594ad22cf6472..98c7479c9c117aca7b9188ee6a9c3a0807b8eb5f 100644
--- a/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DependencyInjection/AutowireTest.php
@@ -137,7 +137,6 @@ public function testCoreServiceAliases(): void {
    * Tests that core controllers are autowired where possible.
    */
   public function testCoreControllerAutowiring(): void {
-    $services = [];
     $aliases = [];
 
     $filenames = array_map(fn($module) => "core/modules/{$module[0]}/{$module[0]}.services.yml", $this->coreModuleListDataProvider());
@@ -173,7 +172,7 @@ public function testCoreControllerAutowiring(): void {
         continue;
       }
       $constructor = new \ReflectionMethod($controller, '__construct');
-      foreach ($constructor->getParameters() as $pos => $parameter) {
+      foreach ($constructor->getParameters() as $parameter) {
         $interface = (string) $parameter->getType();
         if (!isset($aliases[$interface])) {
           continue 2;
diff --git a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
index f81f5ab6a56377b3f72360766b59a9c6649c4c1c..b51cbf26d041c2c7653bc01c092c06afbeca0b8d 100644
--- a/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
+++ b/core/tests/Drupal/KernelTests/Core/DrupalKernel/DrupalKernelTest.php
@@ -318,7 +318,7 @@ public function testLocale(): void {
     // Test environment locale should be UTF-8.
     $this->assertSame($utf8_string, escapeshellcmd($utf8_string));
     $request = Request::createFromGlobals();
-    $kernel = $this->getTestKernel($request);
+    $this->getTestKernel($request);
     // Kernel environment locale should be UTF-8.
     $this->assertSame($utf8_string, escapeshellcmd($utf8_string));
   }
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php b/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php
index 3704d5c6478a84f448a4bf474cc34c7d5cdf5128..635eb3550a8373ffb455be130fe26d68bbb00512 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/BundleClassTest.php
@@ -151,7 +151,7 @@ public function testEntitySubclass(): void {
       $entity_test_1->id(),
       $entity_test_2->id(),
     ];
-    $entities = $this->storage->loadMultiple($entity_ids);
+    $this->storage->loadMultiple($entity_ids);
     // postLoad() should only have been called once more so far.
     $this->assertEquals(2, EntityTestBundleClass::$postLoadCount);
     $this->assertCount(2, EntityTestBundleClass::$postLoadEntitiesCount);
@@ -165,7 +165,7 @@ public function testEntitySubclass(): void {
     // Reset the storage cache and try loading again.
     $this->storage->resetCache();
 
-    $entities = $this->storage->loadMultiple($entity_ids);
+    $this->storage->loadMultiple($entity_ids);
     $this->assertEquals(3, EntityTestBundleClass::$postLoadCount);
     $this->assertCount(3, EntityTestBundleClass::$postLoadEntitiesCount);
     // This time, all 3 bundle_class entities should be included.
@@ -244,7 +244,7 @@ public function testAmbiguousBundleClassExceptionEntityTypeRepository(): void {
     // Now that we have an entity bundle class that's shared by two entirely
     // different entity types, we expect an exception to be thrown.
     $this->expectException(AmbiguousBundleClassException::class);
-    $entity_type = $this->container->get('entity_type.repository')->getEntityTypeFromClass(EntityTestAmbiguousBundleClass::class);
+    $this->container->get('entity_type.repository')->getEntityTypeFromClass(EntityTestAmbiguousBundleClass::class);
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
index 77c71b04baae2dfcc3df9bb2d16e7e6460b941f4..b6051420b4c0c3df86836907584c584a98315024 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityFieldTest.php
@@ -884,7 +884,7 @@ public function testComputedFields(): void {
 
     // Test \Drupal\Core\TypedData\ComputedItemListTrait::getIterator().
     $entity = EntityTestComputedField::create([]);
-    foreach ($entity->computed_string_field as $delta => $item) {
+    foreach ($entity->computed_string_field as $item) {
       $this->assertSame('foo computed', $item->value);
     }
 
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
index 375064f0d0d8989424b84d0576361a507e336a2c..35b18ce53ca3a3219d1bed051d91ba38454267d6 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/EntityTranslationTest.php
@@ -946,7 +946,7 @@ public function testTranslationStatus(): void {
     $entity = $storage->load($entity->id());
     $this->assertEquals(TranslationStatusInterface::TRANSLATION_EXISTING, $entity->getTranslationStatus($entity->language()->getId()));
 
-    foreach ($this->langcodes as $key => $langcode) {
+    foreach ($this->langcodes as $langcode) {
       // Test that after adding a new translation it has the translation status
       // TRANSLATION_CREATED.
       $entity->addTranslation($langcode, $values);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
index 42ea0392141f31cf91f07fab23b9147b0913eb6f..1f0f9762070ddac280a20be38ecd587b2a242454 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/FieldableEntityDefinitionUpdateTest.php
@@ -229,7 +229,7 @@ protected function insertData($revisionable, $translatable): void {
   protected function assertEntityData(bool $revisionable, bool $translatable): void {
     $entities = $this->entityTypeManager->getStorage($this->entityTypeId)->loadMultiple();
     $this->assertCount(3, $entities);
-    foreach ($entities as $entity_id => $entity) {
+    foreach ($entities as $entity) {
       /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
       $this->assertEquals("test entity - {$entity->id()} - en", $entity->label());
       $this->assertEquals("bundle field - {$entity->id()} - en", $entity->new_bundle_field->value);
diff --git a/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php b/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php
index 233c9808a13a1f031e0763d566c0fe8e39b4c45f..be935baf42a7e66317fb2678964f74594cdfa634 100644
--- a/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Entity/ImmutablePropertiesConstraintValidatorTest.php
@@ -56,7 +56,7 @@ public function testValidatorRejectsANonExistentProperty(): void {
 
     $this->expectException(LogicException::class);
     $this->expectExceptionMessage("The entity does not have a 'non_existent' property.");
-    $violations = $this->container->get(TypedDataManagerInterface::class)
+    $this->container->get(TypedDataManagerInterface::class)
       ->create($definition, $entity)
       ->validate();
   }
diff --git a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
index a505e245412c8d9e50cb652bd94615f3c1b1e045..8d9064a53050c866d9896f4ad21da72c4db2ffbf 100644
--- a/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/FileUrlGeneratorTest.php
@@ -43,7 +43,7 @@ protected function setUp(): void {
    */
   public function testGenerateMissingStreamWrapper(): void {
     $this->expectException(InvalidStreamWrapperException::class);
-    $result = $this->fileUrlGenerator->generate("foo://bar");
+    $this->fileUrlGenerator->generate("foo://bar");
   }
 
   /**
@@ -53,7 +53,7 @@ public function testGenerateMissingStreamWrapper(): void {
    */
   public function testGenerateStringMissingStreamWrapper(): void {
     $this->expectException(InvalidStreamWrapperException::class);
-    $result = $this->fileUrlGenerator->generateString("foo://bar");
+    $this->fileUrlGenerator->generateString("foo://bar");
   }
 
   /**
@@ -63,7 +63,7 @@ public function testGenerateStringMissingStreamWrapper(): void {
    */
   public function testGenerateAbsoluteStringMissingStreamWrapper(): void {
     $this->expectException(InvalidStreamWrapperException::class);
-    $result = $this->fileUrlGenerator->generateAbsoluteString("foo://bar");
+    $this->fileUrlGenerator->generateAbsoluteString("foo://bar");
   }
 
   /**
diff --git a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
index 9f76384d93171fbc99e0fd2ff79d1e8b34bb4d3f..b1ebb1c0936be2493e6f61ee6abdd913307defe9 100644
--- a/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
+++ b/core/tests/Drupal/KernelTests/Core/File/StreamWrapperTest.php
@@ -74,8 +74,6 @@ public function testGetInstanceByScheme(): void {
    * Tests the getViaUri() and getViaScheme() methods and target functions.
    */
   public function testUriFunctions(): void {
-    $config = $this->config('system.file');
-
     /** @var \Drupal\Core\StreamWrapper\StreamWrapperManagerInterface $stream_wrapper_manager */
     $stream_wrapper_manager = \Drupal::service('stream_wrapper_manager');
 
diff --git a/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php b/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php
index aa6f76ff69c15e7b220e7567bebaf3df7ee9b954..8bff2c9c330595328aa5f3562194069d466db7ff 100644
--- a/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php
+++ b/core/tests/Drupal/KernelTests/Core/Theme/Stable9TemplateOverrideTest.php
@@ -98,7 +98,7 @@ public function testStable9TemplateOverrides(): void {
 
     $registry_full = $registry->get();
 
-    foreach ($registry_full as $hook => $info) {
+    foreach ($registry_full as $info) {
       if (isset($info['template'])) {
         // Allow skipping templates.
         if (in_array($info['template'], $this->templatesToSkip)) {
diff --git a/core/tests/Drupal/KernelTests/KernelTestBase.php b/core/tests/Drupal/KernelTests/KernelTestBase.php
index 172d70bdfbee627e397fe07e19eb4be89f3676c8..9a78dbf58f5887a3d74784663e6b74958e09d819 100644
--- a/core/tests/Drupal/KernelTests/KernelTestBase.php
+++ b/core/tests/Drupal/KernelTests/KernelTestBase.php
@@ -352,7 +352,6 @@ protected function bootKernel() {
 
     // When a module is providing the database driver, then enable that module.
     $connection_info = Database::getConnectionInfo();
-    $driver = $connection_info['default']['driver'];
     $namespace = $connection_info['default']['namespace'] ?? '';
     $autoload = $connection_info['default']['autoload'] ?? '';
     if (str_contains($autoload, 'src/Driver/Database/')) {
diff --git a/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php
index 4c5bf956fe08df5bb0eefc65600e163c99ff339d..02521bdda2f817a8422a3f296441879365300cdc 100644
--- a/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php
+++ b/core/tests/Drupal/KernelTests/Scripts/TestSiteApplicationTest.php
@@ -89,8 +89,6 @@ public function testInstallWithNonSetupClass(): void {
    * @coversNothing
    */
   public function testInstallScript(): void {
-    $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest';
-
     // Install a site using the JSON output.
     $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"';
     $process = Process::fromShellCommandline($command_line, $this->root);
@@ -186,8 +184,6 @@ public function testInstallScript(): void {
    * @coversNothing
    */
   public function testInstallInDifferentLanguage(): void {
-    $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest';
-
     $command_line = $this->php . ' core/scripts/test-site.php install --json --langcode fr --setup-file core/tests/Drupal/TestSite/TestSiteMultilingualInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"';
     $process = Process::fromShellCommandline($command_line, $this->root);
     $process->setTimeout(500);
@@ -233,7 +229,6 @@ public function testTearDownDbPrefixValidation(): void {
    */
   public function testUserLogin(): void {
     $this->markTestIncomplete('Fix this test in https://www.drupal.org/project/drupal/issues/2962157.');
-    $simpletest_path = $this->root . DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'simpletest';
 
     // Install a site using the JSON output.
     $command_line = $this->php . ' core/scripts/test-site.php install --json --setup-file core/tests/Drupal/TestSite/TestSiteInstallTestScript.php --db-url "' . getenv('SIMPLETEST_DB') . '"';
diff --git a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
index d61e5016bf5fba64b42af2081e75aeaf51b848b5..74ba7f14dfd2740811448fccad47afb8efd854fc 100644
--- a/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
+++ b/core/tests/Drupal/Tests/Component/Datetime/DateTimePlusTest.php
@@ -91,7 +91,7 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte
   public function testInvalidDateDiff($input1, $input2, $absolute): void {
     $this->expectException(\BadMethodCallException::class);
     $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
-    $interval = $input1->diff($input2, $absolute);
+    $input1->diff($input2, $absolute);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
index c3370af5b305f682cd628acea4f06294a33e06ed..28239c71cda160eceb3d5f7df9efad8e3ff6af6d 100644
--- a/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
+++ b/core/tests/Drupal/Tests/Component/DependencyInjection/ContainerTest.php
@@ -72,7 +72,7 @@ public function testConstruct(): void {
     $container_definition = $this->getMockContainerDefinition();
     $container_definition['machine_format'] = !$this->machineFormat;
     $this->expectException(InvalidArgumentException::class);
-    $container = new $this->containerClass($container_definition);
+    new $this->containerClass($container_definition);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
index 17c26a0b36e04b5a026d6769f9df80cfac547348..d5c97bdb8c7ed3081186dd15864fede89988f892 100644
--- a/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
+++ b/core/tests/Drupal/Tests/Component/Gettext/PoHeaderTest.php
@@ -31,8 +31,7 @@ class PoHeaderTest extends TestCase {
    */
   public function testPluralsFormula($plural, $expected): void {
     $p = new PoHeader();
-    $parsed = $p->parsePluralForms($plural);
-    [$nplurals, $new_plural] = $parsed;
+    [, $new_plural] = $p->parsePluralForms($plural);
     foreach ($expected as $number => $plural_form) {
       $result = $new_plural[$number] ?? $new_plural['default'];
       $this->assertEquals($result, $plural_form, 'Difference found at ' . $number . ': ' . $plural_form . ' versus ' . $result);
diff --git a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
index f7a77f6e7db5a9e16f72b17030d81156b6307683..5635173a6de6013eecc224a3040dbdd2eba60f9c 100644
--- a/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
+++ b/core/tests/Drupal/Tests/Component/Utility/RectangleTest.php
@@ -20,7 +20,7 @@ class RectangleTest extends TestCase {
    */
   public function testWrongWidth(): void {
     $this->expectException(\InvalidArgumentException::class);
-    $rect = new Rectangle(-40, 20);
+    new Rectangle(-40, 20);
   }
 
   /**
@@ -30,7 +30,7 @@ public function testWrongWidth(): void {
    */
   public function testWrongHeight(): void {
     $this->expectException(\InvalidArgumentException::class);
-    $rect = new Rectangle(40, 0);
+    new Rectangle(40, 0);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
index 3c38cfbac80574e60e6213e874f364eda5e8dc50..7a75824bef4442959dddf5157fe1acb35fda7f82 100644
--- a/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
+++ b/core/tests/Drupal/Tests/Core/Asset/CssCollectionRendererUnitTest.php
@@ -7,7 +7,6 @@
 use Drupal\Core\Asset\AssetQueryStringInterface;
 use Drupal\Core\Asset\CssCollectionRenderer;
 use Drupal\Core\File\FileUrlGeneratorInterface;
-use Drupal\Core\State\StateInterface;
 use Drupal\Tests\UnitTestCase;
 
 /**
@@ -36,7 +35,6 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
    */
   protected function setUp(): void {
     parent::setUp();
-    $state = $this->prophesize(StateInterface::class);
     $assetQueryString = $this->prophesize(AssetQueryStringInterface::class);
     $file_url_generator = $this->createMock(FileUrlGeneratorInterface::class);
     $file_url_generator->expects($this->any())
diff --git a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
index 7e9ae828063d991f04c94057621640fe88ed4670..15e4cf28aa1a7f621b8e240d1090428f4b46ecb2 100644
--- a/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/ConnectionTest.php
@@ -61,7 +61,7 @@ public function testPrefixRoundTrip($expected, $prefix_info): void {
     // Set the prefix data.
     $set_prefix->invokeArgs($connection, [$prefix_info]);
     // Check the round-trip.
-    foreach ($expected as $table => $prefix) {
+    foreach ($expected as $prefix) {
       $this->assertEquals($prefix, $connection->getPrefix());
     }
   }
diff --git a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
index c915fe5dcda509f96027e63dab7a9fc6c43a32df..e4ee655b3eaba0359b6ac60771c0ff8d5b12394d 100644
--- a/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
+++ b/core/tests/Drupal/Tests/Core/Database/UrlConversionTest.php
@@ -487,7 +487,7 @@ public function testGetInvalidArgumentGetConnectionInfoAsUrl(array $connection_o
     Database::addConnectionInfo('default', 'default', $connection_options);
     $this->expectException(\InvalidArgumentException::class);
     $this->expectExceptionMessage($expected_exception_message);
-    $url = Database::getConnectionInfoAsUrl();
+    Database::getConnectionInfoAsUrl();
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
index e2938730208ab364f9ca44d4194906bcc34b3716..e1ec84395f9d9dd866a67db57370368f5a5e6593 100644
--- a/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
+++ b/core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
@@ -50,7 +50,7 @@ public function testDateDiff($input1, $input2, $absolute, \DateInterval $expecte
   public function testInvalidDateDiff($input1, $input2, $absolute): void {
     $this->expectException(\BadMethodCallException::class);
     $this->expectExceptionMessage('Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
-    $interval = $input1->diff($input2, $absolute);
+    $input1->diff($input2, $absolute);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/DrupalTest.php b/core/tests/Drupal/Tests/Core/DrupalTest.php
index a7394a51d5c5e7b63d3a8258b75cfead39500013..e4f566698821a3f5162b7c6436abd30c8f71b2eb 100644
--- a/core/tests/Drupal/Tests/Core/DrupalTest.php
+++ b/core/tests/Drupal/Tests/Core/DrupalTest.php
@@ -467,7 +467,7 @@ public function testPhpConstants(): void {
    *   The value to return from the mocked container get() method.
    */
   protected function setMockContainerService($service_name, $return = NULL): void {
-    $expects = $this->container->expects($this->once())
+    $this->container->expects($this->once())
       ->method('get')
       ->with($service_name)
       ->willReturn($return ?? new \stdClass());
diff --git a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
index a70c9b4c8ce2b49daf415a6c56aae72ae9a24040..ae2d5c22c22691028a6d077ba7f7f57862f72ed6 100644
--- a/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/BaseFieldDefinitionTest.php
@@ -215,10 +215,6 @@ public function testFieldInitialValue(): void {
     ];
     $expected_default_value = [$default_value];
     $definition->setInitialValue($default_value);
-    $entity = $this->getMockBuilder(ContentEntityBaseMockableClass::class)
-      ->disableOriginalConstructor()
-      ->onlyMethods([])
-      ->getMock();
     // Set the field item list class to be used to avoid requiring the typed
     // data manager to retrieve it.
     $definition->setClass('Drupal\Core\Field\FieldItemList');
diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
index e573bf54d350fbf0a787150df1659cb76dcccab2..243069049c70e6ab394c21eba39290ad465bc618 100644
--- a/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/EntityFieldManagerTest.php
@@ -313,7 +313,7 @@ public function testGetFieldStorageDefinitions(): void {
     $this->moduleHandler->invokeAllWith('entity_base_field_info', Argument::any());
     $this->moduleHandler->invokeAllWith('entity_field_storage_info', Argument::any())
       ->will(function ($arguments) use ($definitions) {
-        [$hook, $callback] = $arguments;
+        [, $callback] = $arguments;
         $callback(
           function () use ($definitions) {
             return $definitions;
@@ -486,7 +486,7 @@ public function testGetFieldStorageDefinitionsWithCaching(): void {
 
     $this->moduleHandler->invokeAllWith('entity_field_storage_info', Argument::any())
       ->will(function ($arguments) use ($definitions) {
-        [$hook, $callback] = $arguments;
+        [, $callback] = $arguments;
         $callback(
           function () use ($definitions) {
             return $definitions;
@@ -562,7 +562,7 @@ public function testGetFieldDefinitionsProvider(): void {
 
     $this->moduleHandler->invokeAllWith(Argument::type('string'), Argument::any())
       ->will(function ($arguments) use ($field_definition, $module) {
-        [$hook, $callback] = $arguments;
+        [, $callback] = $arguments;
         $callback(
           function () use ($field_definition) {
             return [$field_definition->reveal()];
diff --git a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
index c66e726693dfeee72ee73b28880a9644f69b0fbb..053c05ebd97e2e9612e7987320b6ad1df2eda6fd 100644
--- a/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
+++ b/core/tests/Drupal/Tests/Core/Entity/Routing/DefaultHtmlRouteProviderTest.php
@@ -387,7 +387,7 @@ public function testGetEntityTypeIdKeyTypeNotFieldable(): void {
   protected static function getEntityType(?ObjectProphecy $base_entity_type = NULL) {
     $entity_type = (new Prophet())->prophesize(EntityTypeInterface::class);
     if ($base_entity_type) {
-      foreach ($base_entity_type->getMethodProphecies() as $method => $prophecies) {
+      foreach ($base_entity_type->getMethodProphecies() as $prophecies) {
         foreach ($prophecies as $prophecy) {
           $entity_type->addMethodProphecy(clone $prophecy);
         }
diff --git a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
index b5b80a1bf0e41159c9c407b54b5fbd84c509b2d8..a1b8d4c9c4c0ee9ad41f1c4174875b436222243c 100644
--- a/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
+++ b/core/tests/Drupal/Tests/Core/PathProcessor/PathProcessorTest.php
@@ -51,14 +51,6 @@ protected function setUp(): void {
     }
     $this->languages = $languages;
 
-    // Create a stub configuration.
-    $language_prefixes = array_keys($this->languages);
-    $config = [
-      'url' => [
-        'prefixes' => array_combine($language_prefixes, $language_prefixes),
-      ],
-    ];
-
     // Create a language manager stub.
     $language_manager = $this->getMockBuilder('Drupal\language\ConfigurableLanguageManagerInterface')
       ->getMock();
diff --git a/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php
index 64e0d24231884f4a2533351ebb5ca6e4ca246d5b..6368b23fa4e091a5a2e07b045d094d04cf6af596 100644
--- a/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/MetadataBubblingUrlGeneratorTest.php
@@ -53,8 +53,6 @@ protected function setUp(): void {
    * @dataProvider providerUrlBubbleableMetadataBubbling
    */
   public function testUrlBubbleableMetadataBubbling($collect_bubbleable_metadata, $invocations, array $options): void {
-    $self = $this;
-
     $this->renderer->expects($this->exactly($invocations))
       ->method('render')
       ->willReturnCallback(function ($build) {
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
index cd720518007269f0a7bd44a4564774e962c30560..3f05b89465ce1a77d2c198ab0158f0328ebbf408 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererPlaceholdersTest.php
@@ -149,7 +149,7 @@ public static function providerPlaceholders(): array {
     // Note the absence of '#create_placeholder', presence of max-age=0 created
     // by the #lazy_builder callback.
     // @todo in https://www.drupal.org/node/2559847
-    $base_element_a5 = [];
+    //   $base_element_a5 = [];
     // Note the absence of '#create_placeholder', presence of high cardinality
     // cache context created by the #lazy_builder callback.
     // @see \Drupal\Tests\Core\Render\PlaceholdersTest::callbackPerUser()
@@ -1074,8 +1074,8 @@ public function testRenderLazyBuilderPreview(): void {
 
     $element1 = $element2 = $test_element;
     // Render the element twice so that it is in the render cache.
-    $result = $this->renderer->renderRoot($element1);
-    $result = $this->renderer->renderRoot($element2);
+    $this->renderer->renderRoot($element1);
+    $this->renderer->renderRoot($element2);
     $placeholder_string = (string) $this->renderCache->placeholderElements[0]['#markup'];
     $this->assertSame($this->renderCache->placeholderElements[0]['#attached']['placeholders'][$placeholder_string]['#preview'], ['#markup' => 'Lazy Builder Preview']);
   }
diff --git a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
index 29b0c7b183e969ef3d35d0b4a802b83e49cce29a..3e7981c0a3cc3a13d56a2468b11d997070206eba 100644
--- a/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
+++ b/core/tests/Drupal/Tests/Core/Render/RendererRecursionTest.php
@@ -11,7 +11,6 @@
 class RendererRecursionTest extends RendererTestBase {
 
   protected function setUpRenderRecursionComplexElements(): array {
-    $complex_child_markup = '<p>Imagine this is a render array for an entity.</p>';
     $parent_markup = '<p>Rendered!</p>';
 
     $complex_child_template = [
@@ -24,7 +23,7 @@ protected function setUpRenderRecursionComplexElements(): array {
       '#create_placeholder' => TRUE,
     ];
 
-    return [$complex_child_markup, $parent_markup, $complex_child_template];
+    return [$parent_markup, $complex_child_template];
   }
 
   /**
@@ -35,7 +34,7 @@ protected function setUpRenderRecursionComplexElements(): array {
    * @covers ::doRender
    */
   public function testRenderRecursionWithNestedRenderRoot(): void {
-    [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
+    [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
     $renderer = $this->renderer;
     $this->setUpRequest();
 
@@ -67,7 +66,7 @@ public function testRenderRecursionWithNestedRenderRoot(): void {
    * @covers ::doRender
    */
   public function testRenderRecursionWithNestedRender(): void {
-    [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
+    [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
     $renderer = $this->renderer;
     $this->setUpRequest();
 
@@ -101,7 +100,7 @@ public function testRenderRecursionWithNestedRender(): void {
    * @covers ::renderInIsolation
    */
   public function testRenderRecursionWithNestedRenderInIsolation(): void {
-    [$complex_child_markup, $parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
+    [$parent_markup, $complex_child_template] = $this->setUpRenderRecursionComplexElements();
     $renderer = $this->renderer;
     $this->setUpRequest();
 
diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php
index 6e310ea4dea7684bcbf5cca2e45efd1df29fb2de..6c584864ba0fd091d4898be932402d4e27eba5ae 100644
--- a/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/Icon/IconDefinitionTest.php
@@ -222,8 +222,6 @@ public function testCreateIconHumanize(string $icon_id, string $expected): void
    * Test the IconDefinition::getRenderable method.
    */
   public function testGetRenderable(): void {
-    $icon = IconDefinition::create('foo', 'bar', '_template_');
-
     $expected = [
       '#type' => 'icon',
       '#pack_id' => 'foo',
diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php
index 3c13329d228fd12636379ae0fdbcba7a8eb13d62..32f89e340d6f59210600021bf0852a3623da6229 100644
--- a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/PathExtractorTest.php
@@ -125,7 +125,7 @@ public function testDiscoverIconsPath(array $files, bool $expected_empty = FALSE
 
     // Result expected is keyed by icon_id with values 'source' and 'group'.
     $expected_result = [];
-    foreach ($files as $index => $icon) {
+    foreach ($files as $icon) {
       $expected_id = $this->pluginId . IconDefinition::ICON_SEPARATOR . $icon['icon_id'];
       if (!isset($icon['group'])) {
         $icon['group'] = NULL;
diff --git a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php
index 96c1a4425db43da1c9544977190415ab10e74b9d..0f1146f84d89a576d3d663c036182ed831e18e53 100644
--- a/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php
+++ b/core/tests/Drupal/Tests/Core/Theme/Icon/Plugin/SvgExtractorTest.php
@@ -129,7 +129,7 @@ public function testDiscoverIconsSvg(array $files, bool $expected_empty = FALSE)
     }
 
     $expected_result = [];
-    foreach ($files as $index => $icon) {
+    foreach ($files as $icon) {
       $expected_id = $this->pluginId . IconDefinition::ICON_SEPARATOR . $icon['icon_id'];
       $expected_result[$expected_id] = [
         'source' => $icon['source'],
diff --git a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
index 46fb739c7e12f8709caf291c93930d207ec23e48..d27e22c74a15ff8876b3d6786f830b7c1fde7822 100644
--- a/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UnroutedUrlTest.php
@@ -106,7 +106,7 @@ public static function providerFromUri() {
    */
   public function testFromInvalidUri($uri): void {
     $this->expectException(\InvalidArgumentException::class);
-    $url = Url::fromUri($uri);
+    Url::fromUri($uri);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/Core/UrlTest.php b/core/tests/Drupal/Tests/Core/UrlTest.php
index 840b570db8a18a3b743eaa3a6f4d50a97195df41..09e54efb1c180d2fa2bed8bee5ce1badac1a5812 100644
--- a/core/tests/Drupal/Tests/Core/UrlTest.php
+++ b/core/tests/Drupal/Tests/Core/UrlTest.php
@@ -193,7 +193,7 @@ public function testFromUserInput($path): void {
    */
   public function testFromInvalidUserInput($path): void {
     $this->expectException(\InvalidArgumentException::class);
-    $url = Url::fromUserInput($path);
+    Url::fromUserInput($path);
   }
 
   /**
diff --git a/core/tests/Drupal/Tests/PerformanceTestTrait.php b/core/tests/Drupal/Tests/PerformanceTestTrait.php
index b722ebde8d76e0a94cefbf8c3fe79550bb7b1420..50d0ce5ed6253ee6234ce1424a4472b91303efd5 100644
--- a/core/tests/Drupal/Tests/PerformanceTestTrait.php
+++ b/core/tests/Drupal/Tests/PerformanceTestTrait.php
@@ -503,7 +503,7 @@ private function openTelemetryTracing(array $messages, string $service_name): vo
       $collection = \Drupal::keyValue('performance_test');
       $performance_test_data = $collection->get('performance_test_data');
       $query_events = $performance_test_data['database_events'] ?? [];
-      foreach ($query_events as $key => $event) {
+      foreach ($query_events as $event) {
         if (static::isDatabaseCache($event)) {
           continue;
         }
diff --git a/core/tests/bootstrap.php b/core/tests/bootstrap.php
index 60c0f6916871174212c52a8e5cadd7944cfe8c5c..1467313b6ff8e13a778384b9f74604fdf40a4cb9 100644
--- a/core/tests/bootstrap.php
+++ b/core/tests/bootstrap.php
@@ -144,7 +144,7 @@ function drupal_phpunit_populate_class_loader() {
 }
 
 // Do class loader population.
-$loader = drupal_phpunit_populate_class_loader();
+drupal_phpunit_populate_class_loader();
 class_alias('\Drupal\Tests\DocumentElement', '\Behat\Mink\Element\DocumentElement', TRUE);
 
 // Set sane locale settings, to ensure consistent string, dates, times and