diff --git a/core/includes/common.inc b/core/includes/common.inc
index 799a5e97570f01f32a562ad59762e736c88cc526..5bc02f1eb71a11c59aa4d597cc4c49f136025ea0 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -543,7 +543,7 @@ function drupal_flush_all_caches($kernel = NULL) {
   $module_handler = \Drupal::moduleHandler();
   // Flush all persistent caches.
   $module_handler->invokeAll('cache_flush');
-  foreach (Cache::getBins() as $service_id => $cache_backend) {
+  foreach (Cache::getBins() as $cache_backend) {
     $cache_backend->deleteAll();
   }
 
diff --git a/core/includes/install.core.inc b/core/includes/install.core.inc
index 6c492363da7756bec0dc45d459f2f88a1f1ff63e..6d83278cfe6aba05ebdaef3a95cfa60277fed149 100644
--- a/core/includes/install.core.inc
+++ b/core/includes/install.core.inc
@@ -1173,7 +1173,7 @@ function install_verify_database_ready() {
   $table = key($system_schema);
 
   $existing_install = FALSE;
-  if ($database = Database::getConnectionInfo()) {
+  if (Database::getConnectionInfo()) {
     try {
       $existing_install = Database::getConnection()->schema()->tableExists($table);
     }
@@ -2424,7 +2424,6 @@ function install_config_revert_install_changes() {
       $config_importer->import();
     }
     catch (ConfigImporterException $e) {
-      global $install_state;
       $messenger = \Drupal::messenger();
       // There are validation errors.
       $messenger->addError(t('The configuration synchronization failed validation.'));
diff --git a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
index 889d2667270f992eec837f60c79b33a9638cd84b..be177a8b8ba464ea46b2afad24eab80991d82baf 100644
--- a/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
+++ b/core/lib/Drupal/Component/DependencyInjection/Dumper/OptimizedPhpArrayDumper.php
@@ -250,8 +250,8 @@ protected function getServiceDefinition(Definition $definition) {
       $service['shared'] = $definition->isShared();
     }
 
-    if (($decorated = $definition->getDecoratedService()) !== NULL) {
-      throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal 8 run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
+    if ($definition->getDecoratedService() !== NULL) {
+      throw new InvalidArgumentException("The 'decorated' definition is not supported by the Drupal run-time container. The Container Builder should have resolved that during the DecoratorServicePass compiler pass.");
     }
 
     if ($callable = $definition->getFactory()) {
diff --git a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
index eda980cfd8ae73b2f3e4b3031d0be754e0475f73..323b8e37f29b163650d414db441258111dbb23ac 100644
--- a/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
+++ b/core/lib/Drupal/Component/EventDispatcher/ContainerAwareEventDispatcher.php
@@ -130,8 +130,8 @@ public function dispatch($event/*, string $event_name = NULL*/) {
       }
 
       // Invoke listeners and resolve callables if necessary.
-      foreach ($this->listeners[$event_name] as $priority => &$definitions) {
-        foreach ($definitions as $key => &$definition) {
+      foreach ($this->listeners[$event_name] as &$definitions) {
+        foreach ($definitions as &$definition) {
           if (!isset($definition['callable'])) {
             $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
           }
@@ -173,8 +173,8 @@ public function getListeners($event_name = NULL): array {
       }
 
       // Collect listeners and resolve callables if necessary.
-      foreach ($this->listeners[$event_name] as $priority => &$definitions) {
-        foreach ($definitions as $key => &$definition) {
+      foreach ($this->listeners[$event_name] as &$definitions) {
+        foreach ($definitions as &$definition) {
           if (!isset($definition['callable'])) {
             $definition['callable'] = [$this->container->get($definition['service'][0]), $definition['service'][1]];
           }
@@ -202,7 +202,7 @@ public function getListenerPriority($event_name, $listener): ?int {
     }
     // Resolve service definitions if the listener has not been found so far.
     foreach ($this->listeners[$event_name] as $priority => &$definitions) {
-      foreach ($definitions as $key => &$definition) {
+      foreach ($definitions as &$definition) {
         if (!isset($definition['callable'])) {
           // Once the callable is retrieved we keep it for subsequent method
           // invocations on this class.
diff --git a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
index 65d7926e6d5680e332d83659bf43a37e33af67fe..63d72bccb47318ab2a3517c19a04f2b03b47a43a 100644
--- a/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
+++ b/core/lib/Drupal/Component/ProxyBuilder/ProxyBuilder.php
@@ -79,7 +79,7 @@ public function build($class_name) {
     // In order to avoid that, check for each interface, whether one of its
     // parents is also in the list and exclude it.
     if ($interfaces = $reflection->getInterfaces()) {
-      foreach ($interfaces as $interface_name => $interface) {
+      foreach ($interfaces as $interface) {
         // Exclude all parents from the list of implemented interfaces of the
         // class.
         if ($parent_interfaces = $interface->getInterfaceNames()) {
diff --git a/core/lib/Drupal/Core/Access/AccessResult.php b/core/lib/Drupal/Core/Access/AccessResult.php
index 29836fbd6c0447966d5e8d034776d6eab34234a8..ee7d96a683603302e88497f7b8eb1fab680b8b74 100644
--- a/core/lib/Drupal/Core/Access/AccessResult.php
+++ b/core/lib/Drupal/Core/Access/AccessResult.php
@@ -143,7 +143,7 @@ public static function allowedIfHasPermissions(AccountInterface $account, array
     if ($conjunction == 'AND' && !empty($permissions)) {
       $access = TRUE;
       foreach ($permissions as $permission) {
-        if (!$permission_access = $account->hasPermission($permission)) {
+        if (!$account->hasPermission($permission)) {
           $access = FALSE;
           break;
         }
@@ -151,7 +151,7 @@ public static function allowedIfHasPermissions(AccountInterface $account, array
     }
     else {
       foreach ($permissions as $permission) {
-        if ($permission_access = $account->hasPermission($permission)) {
+        if ($account->hasPermission($permission)) {
           $access = TRUE;
           break;
         }
diff --git a/core/lib/Drupal/Core/Asset/CssOptimizer.php b/core/lib/Drupal/Core/Asset/CssOptimizer.php
index 22f6cdb9abac0ad7e3d6a37241c55183785f857c..c01a1ba8717458de0e6f5cdd3d9d9ce532550985 100644
--- a/core/lib/Drupal/Core/Asset/CssOptimizer.php
+++ b/core/lib/Drupal/Core/Asset/CssOptimizer.php
@@ -71,7 +71,16 @@ public function clean($contents) {
   }
 
   /**
-   * Build aggregate CSS file.
+   * Processes CSS file and adds base URLs to any relative resource paths.
+   *
+   * @param array $css_asset
+   *   A CSS asset. The array should contain the `data` key where the value
+   *   should be the path to the CSS file relative to the Drupal root. This is
+   *   an example of the `data` key's value,
+   *   "core/assets/vendor/normalize-css/normalize.css".
+   *
+   * @return string
+   *   The asset's cleaned/optimized contents.
    */
   protected function processFile($css_asset) {
     $contents = $this->loadFile($css_asset['data'], TRUE);
diff --git a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
index 9392d565109c196e3e983e3431fe7d7b160fd4d7..0c79535938580f9dceeb06f52d16f588fd7d6464 100644
--- a/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
+++ b/core/lib/Drupal/Core/Asset/LibraryDiscoveryParser.php
@@ -544,7 +544,7 @@ public static function validateCssLibrary($library) {
         return 2;
       }
       $categories[] = $category;
-      foreach ($files as $source => $options) {
+      foreach ($files as $options) {
         if (!is_array($options)) {
           return 1;
         }
diff --git a/core/lib/Drupal/Core/Database/Database.php b/core/lib/Drupal/Core/Database/Database.php
index 79b681dc883a0f168ab4d7f39e4f5e1be05c59d4..96af8c5741d9d2acfc9b84c01563f3d2b140d994 100644
--- a/core/lib/Drupal/Core/Database/Database.php
+++ b/core/lib/Drupal/Core/Database/Database.php
@@ -398,7 +398,7 @@ final protected static function openConnection($key, $target) {
       throw new ConnectionNotDefinedException('The specified database connection is not defined: ' . $key);
     }
 
-    if (!$driver = self::$databaseInfo[$key][$target]['driver']) {
+    if (!self::$databaseInfo[$key][$target]['driver']) {
       throw new DriverNotSpecifiedException('Driver not specified for this database connection: ' . $key);
     }
 
diff --git a/core/lib/Drupal/Core/Entity/ContentEntityBase.php b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
index ee965898bc6aaa555a398bc4684f5d2546012564..75dd42564b2b8edd7f57fd3d8d4f7f92c0481a30 100644
--- a/core/lib/Drupal/Core/Entity/ContentEntityBase.php
+++ b/core/lib/Drupal/Core/Entity/ContentEntityBase.php
@@ -769,7 +769,7 @@ protected function setDefaultLangcode() {
    * Updates language for already instantiated fields.
    */
   protected function updateFieldLangcodes($langcode) {
-    foreach ($this->fields as $name => $items) {
+    foreach ($this->fields as $items) {
       if (!empty($items[LanguageInterface::LANGCODE_DEFAULT])) {
         $items[LanguageInterface::LANGCODE_DEFAULT]->setLangcode($langcode);
       }
diff --git a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
index aaa26ecfc708bf8ea571eeb8f1dc9247078ea4e4..c31a4044145cfb8a339e5ff61d17c8b915fb662b 100644
--- a/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
+++ b/core/lib/Drupal/Core/Entity/EntityConstraintViolationList.php
@@ -106,7 +106,7 @@ public function getByField($field_name) {
   public function getByFields(array $field_names) {
     $this->groupViolationOffsets();
     $violations = [];
-    foreach (array_intersect_key($this->violationOffsetsByField, array_flip($field_names)) as $field_name => $offsets) {
+    foreach (array_intersect_key($this->violationOffsetsByField, array_flip($field_names)) as $offsets) {
       foreach ($offsets as $offset) {
         $violations[] = $this->get($offset);
       }
diff --git a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
index 7dce1ff3c307198ea97c3fb6a9bead4541955829..ee078171871f525d5ac88f876188d3e09c64f26f 100644
--- a/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityDisplayBase.php
@@ -276,7 +276,7 @@ public function calculateDependencies() {
     if (\Drupal::moduleHandler()->moduleExists('field')) {
       $components = $this->content + $this->hidden;
       $field_definitions = \Drupal::service('entity_field.manager')->getFieldDefinitions($this->targetEntityType, $this->bundle);
-      foreach (array_intersect_key($field_definitions, $components) as $field_name => $field_definition) {
+      foreach (array_intersect_key($field_definitions, $components) as $field_definition) {
         if ($field_definition instanceof ConfigEntityInterface && $field_definition->getEntityTypeId() == 'field_config') {
           $this->addDependency('config', $field_definition->getConfigDependencyName());
         }
diff --git a/core/lib/Drupal/Core/Entity/EntityStorageBase.php b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
index ce9e78c53a3e4b4d0a4335ba381d09d135ab2c9e..6fccb37b11b492b1cbecbb78a64acd4ad42e2b35 100644
--- a/core/lib/Drupal/Core/Entity/EntityStorageBase.php
+++ b/core/lib/Drupal/Core/Entity/EntityStorageBase.php
@@ -229,7 +229,7 @@ protected function getFromStaticCache(array $ids) {
    */
   protected function setStaticCache(array $entities) {
     if ($this->entityType->isStaticallyCacheable()) {
-      foreach ($entities as $id => $entity) {
+      foreach ($entities as $entity) {
         $this->memoryCache->set($this->buildCacheId($entity->id()), $entity, MemoryCacheInterface::CACHE_PERMANENT, [$this->memoryCacheTag]);
       }
     }
diff --git a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
index 266886ba954d43988d4a8d4c87e829ea7cb4740e..42cbb5713f5683c160bedbcfda7c299ca8d64d9e 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionDiscovery.php
@@ -279,7 +279,7 @@ protected function filterByProfileDirectories(array $all_files) {
         return TRUE;
       }
 
-      foreach ($this->profileDirectories as $weight => $profile_path) {
+      foreach ($this->profileDirectories as $profile_path) {
         if (strpos($file->getPath(), $profile_path) === 0) {
           // Parent profile found.
           return TRUE;
diff --git a/core/lib/Drupal/Core/Extension/ExtensionList.php b/core/lib/Drupal/Core/Extension/ExtensionList.php
index dd538d1c9198dd24ab426cc2282a154d4257d0d6..0ac671965b2092da39d9710e1e9fcb527c6b27aa 100644
--- a/core/lib/Drupal/Core/Extension/ExtensionList.php
+++ b/core/lib/Drupal/Core/Extension/ExtensionList.php
@@ -312,7 +312,7 @@ protected function doList() {
     $extensions = $this->doScanExtensions();
 
     // Read info files for each extension.
-    foreach ($extensions as $extension_name => $extension) {
+    foreach ($extensions as $extension) {
       $extension->info = $this->createExtensionInfo($extension);
 
       // Invoke hook_system_info_alter() to give installed modules a chance to
diff --git a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
index 5aed60c0b04ca6dcd6de6879e155c6e073570b1e..6337cd08940b16fb66c986b787585da0db1e8ba6 100644
--- a/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
+++ b/core/lib/Drupal/Core/Extension/ModuleExtensionList.php
@@ -88,7 +88,7 @@ public function __construct($root, $type, CacheBackendInterface $cache, InfoPars
   protected function getExtensionDiscovery() {
     $discovery = parent::getExtensionDiscovery();
 
-    if ($active_profile = $this->getActiveProfile()) {
+    if ($this->getActiveProfile()) {
       $discovery->setProfileDirectories($this->getProfileDirectories($discovery));
     }
 
diff --git a/core/lib/Drupal/Core/Extension/ModuleInstaller.php b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
index 21970253e91b8fc50cfed9236772f7a705146245..8b24bcdf123c8ac058fa3cd9f7d8dd592fa75d53 100644
--- a/core/lib/Drupal/Core/Extension/ModuleInstaller.php
+++ b/core/lib/Drupal/Core/Extension/ModuleInstaller.php
@@ -561,7 +561,7 @@ public function uninstall(array $module_list, $uninstall_dependents = TRUE) {
     // Any cache entry might implicitly depend on the uninstalled modules,
     // so clear all of them explicitly.
     $this->moduleHandler->invokeAll('cache_flush');
-    foreach (Cache::getBins() as $service_id => $cache_backend) {
+    foreach (Cache::getBins() as $cache_backend) {
       $cache_backend->deleteAll();
     }
 
diff --git a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php
index 3b065b603d47489d065816597093e24b4eb43839..e3a427f9c8314ef25599055c21dc48513d47f02d 100644
--- a/core/lib/Drupal/Core/Extension/ThemeExtensionList.php
+++ b/core/lib/Drupal/Core/Extension/ThemeExtensionList.php
@@ -142,7 +142,7 @@ protected function doList() {
     // sub-themes.
     $this->fillInSubThemeData($themes, $sub_themes);
 
-    foreach ($themes as $key => $theme) {
+    foreach ($themes as $theme) {
       // After $theme is processed by buildModuleDependencies(), there can be a
       // `$theme->requires` array containing both module and base theme
       // dependencies. The module dependencies are copied to their own property
diff --git a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
index dbe2762d940c10ce5f03755b43387ef2ec545ca3..0bf634ea5ea66552f879c6475f9a1ab393ebd1fe 100644
--- a/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
+++ b/core/lib/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.php
@@ -345,7 +345,7 @@ public static function generateSampleValue(FieldDefinitionInterface $field_defin
    *   Either the bundle string, or NULL if there is no bundle.
    */
   protected static function getRandomBundle(EntityTypeInterface $entity_type, array $selection_settings) {
-    if ($bundle_key = $entity_type->getKey('bundle')) {
+    if ($entity_type->getKey('bundle')) {
       if (!empty($selection_settings['target_bundles'])) {
         $bundle_ids = $selection_settings['target_bundles'];
       }
diff --git a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
index d42f7ab90158827c0b9c17a1bd3b6ca4ee18697f..90a2c4257e3beded662b127875759d34b0d4ea1b 100644
--- a/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
+++ b/core/lib/Drupal/Core/File/MimeType/MimeTypeGuesser.php
@@ -73,6 +73,8 @@ public function guessMimeType(string $path) : ?string {
         return $mime_type;
       }
     }
+
+    return NULL;
   }
 
   /**
diff --git a/core/lib/Drupal/Core/Flood/DatabaseBackend.php b/core/lib/Drupal/Core/Flood/DatabaseBackend.php
index c1da5dd40f474b9a2a5852e059bdd87b34c37e84..7caef173e3fc8af1546888382533574b5d8540c6 100644
--- a/core/lib/Drupal/Core/Flood/DatabaseBackend.php
+++ b/core/lib/Drupal/Core/Flood/DatabaseBackend.php
@@ -135,7 +135,7 @@ public function isAllowed($name, $threshold, $window = 3600, $identifier = NULL)
    */
   public function garbageCollection() {
     try {
-      $return = $this->connection->delete(static::TABLE_NAME)
+      $this->connection->delete(static::TABLE_NAME)
         ->condition('expiration', REQUEST_TIME, '<')
         ->execute();
     }
diff --git a/core/lib/Drupal/Core/Form/FormErrorHandler.php b/core/lib/Drupal/Core/Form/FormErrorHandler.php
index 695f023a73bb3600315ee1cbcac6daf5757cbc6d..dfb52c072ee0d17727abfc2fa962b1c2efe96e94 100644
--- a/core/lib/Drupal/Core/Form/FormErrorHandler.php
+++ b/core/lib/Drupal/Core/Form/FormErrorHandler.php
@@ -18,7 +18,7 @@ class FormErrorHandler implements FormErrorHandlerInterface {
    */
   public function handleFormErrors(array &$form, FormStateInterface $form_state) {
     // After validation check if there are errors.
-    if ($errors = $form_state->getErrors()) {
+    if ($form_state->getErrors()) {
       // Display error messages for each element.
       $this->displayErrorMessages($form, $form_state);
 
@@ -110,6 +110,7 @@ protected function setElementErrorsFromFormState(array &$form, FormStateInterfac
     // modify the original form. When processing grouped elements a reference to
     // the complete form is needed.
     if (empty($elements)) {
+      // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.VariableRedeclaration
       $elements = &$form;
     }
 
diff --git a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
index ecae57c7cd364eb5d45414ff126d34e1b9b72c3f..bf8ca0f1400d3fc03966c75d5f4bb00a556d53b5 100644
--- a/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
+++ b/core/lib/Drupal/Core/Menu/MenuParentFormSelector.php
@@ -88,7 +88,7 @@ public function parentSelectElement($menu_parent, $id = '', array $menus = NULL)
       if (!isset($options[$menu_parent])) {
         // The requested menu parent cannot be found in the menu anymore. Try
         // setting it to the top level in the current menu.
-        [$menu_name, $parent] = explode(':', $menu_parent, 2);
+        [$menu_name] = explode(':', $menu_parent, 2);
         $menu_parent = $menu_name . ':';
       }
       if (isset($options[$menu_parent])) {
diff --git a/core/lib/Drupal/Core/Template/Attribute.php b/core/lib/Drupal/Core/Template/Attribute.php
index 1ad25dd9cda8e23ba85738248af7a52c022c4d54..aeb044a3b4a111f4951aeefaf72afe0a29844ecb 100644
--- a/core/lib/Drupal/Core/Template/Attribute.php
+++ b/core/lib/Drupal/Core/Template/Attribute.php
@@ -320,7 +320,7 @@ public function hasClass($class) {
   public function __toString() {
     $return = '';
     /** @var \Drupal\Core\Template\AttributeValueBase $value */
-    foreach ($this->storage as $name => $value) {
+    foreach ($this->storage as $value) {
       $rendered = $value->render();
       if ($rendered) {
         $return .= ' ' . $rendered;
diff --git a/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php
index ff13f50aeb797433d3286f7b2b3d3ad4d13fcdd7..51eb7b76b45639eca4746ea9537ed2e2ae06da2f 100644
--- a/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php
+++ b/core/lib/Drupal/Core/Test/HttpClientMiddleware/TestHttpClientMiddleware.php
@@ -29,7 +29,7 @@ public function __invoke() {
           $request = $request->withHeader('User-Agent', drupal_generate_test_ua($test_prefix));
         }
         return $handler($request, $options)
-          ->then(function (ResponseInterface $response) use ($request) {
+          ->then(function (ResponseInterface $response) {
             if (!drupal_valid_test_ua()) {
               return $response;
             }
diff --git a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php
index 09a2dc2679597d0fb56c747e489fd4a4e4f128e2..f1d4d4236b2e2d62f23ae1b7afa449790acd6dd8 100644
--- a/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php
+++ b/core/lib/Drupal/Core/TypedData/ComputedItemListTrait.php
@@ -118,6 +118,7 @@ public function isEmpty() {
   /**
    * {@inheritdoc}
    */
+  #[\ReturnTypeWillChange]
   public function offsetExists($offset) {
     $this->ensureComputedValue();
     return parent::offsetExists($offset);
diff --git a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
index 90513008f30219138ed90ba14e66e7f3c283a3f8..5a8ab698432aef61d035410a4b40a4ca6c91af89 100644
--- a/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
+++ b/core/lib/Drupal/Core/TypedData/Validation/RecursiveContextualValidator.php
@@ -154,7 +154,7 @@ protected function validateNode(TypedDataInterface $data, $constraints = NULL, $
     // entity, since we should determine whether the entity matches the
     // constraints and not whether the entity validates.
     if (($data instanceof ListInterface || $data instanceof ComplexDataInterface) && !$data->isEmpty() && !($data instanceof EntityAdapter && $constraints_given)) {
-      foreach ($data as $name => $property) {
+      foreach ($data as $property) {
         $this->validateNode($property);
       }
     }
diff --git a/core/misc/cspell/dictionary.txt b/core/misc/cspell/dictionary.txt
index 4a664b782cecbd9421164668b84e068684ef3c7d..b86c6c02771ed31aee16ccebf285d6f790606d23 100644
--- a/core/misc/cspell/dictionary.txt
+++ b/core/misc/cspell/dictionary.txt
@@ -1119,6 +1119,7 @@ realword
 rebuilder
 reclosed
 recolorable
+redeclaration
 redirections
 redstrawberryhiddenfield
 refactorings
diff --git a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
index 1e471a2cf72b580d2fe0304cd37e69929f490c76..73444dfab1fd2c7d99ed2ec1ea138ac15f55f869 100644
--- a/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
+++ b/core/modules/block/src/Plugin/migrate/process/BlockPluginId.php
@@ -76,7 +76,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
       [$module, $delta] = $value;
       switch ($module) {
         case 'aggregator':
-          [$type, $id] = explode('-', $delta);
+          [$type] = explode('-', $delta);
           if ($type == 'feed') {
             return 'aggregator_feed_block';
           }
diff --git a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php
index 618cd3c5951f708fe014a3ec3da2fc83a410bc68..9f3e5bb4e1d34794f4c899a414f660c20834608a 100644
--- a/core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php
+++ b/core/modules/ckeditor5/src/Plugin/Validation/Constraint/SourceEditingRedundantTagsConstraintValidator.php
@@ -82,7 +82,7 @@ public function validate($value, Constraint $constraint) {
   private function pluginsSupplyingTagsMessage(array $tags, array $plugin_definitions): string {
     $message_array = [];
     $message_string = '';
-    foreach ($plugin_definitions as $plugin_id => $definition) {
+    foreach ($plugin_definitions as $definition) {
       if ($definition->hasElements()) {
         $elements_array = HTMLRestrictionsUtilities::allowedElementsStringToHtmlFilterArray(implode('', $definition->getElements()));
         foreach ($elements_array as $tag_name => $tag_config) {
diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module
index 71c0202b4214484a70bbdf8e98db96d86cbb1c34..e1a496ba5742fe466e56e61edc205096ac9f2f77 100644
--- a/core/modules/comment/comment.module
+++ b/core/modules/comment/comment.module
@@ -712,7 +712,7 @@ function comment_entity_view_display_presave(EntityViewDisplayInterface $display
   }
 
   // Disable the comment field formatter when the used view display is disabled.
-  foreach ($storage->loadMultiple() as $id => $view_display) {
+  foreach ($storage->loadMultiple() as $view_display) {
     $changed = FALSE;
     /** @var \Drupal\Core\Entity\Display\EntityViewDisplayInterface $view_display */
     foreach ($view_display->getComponents() as $field => $component) {
diff --git a/core/modules/comment/src/CommentFieldItemList.php b/core/modules/comment/src/CommentFieldItemList.php
index 60311ceeba478509d552dac63c0427513532caf5..985f8652250dbf816475f0968eea80b67994c3eb 100644
--- a/core/modules/comment/src/CommentFieldItemList.php
+++ b/core/modules/comment/src/CommentFieldItemList.php
@@ -30,6 +30,7 @@ public function get($index) {
   /**
    * {@inheritdoc}
    */
+  #[\ReturnTypeWillChange]
   public function offsetExists($offset) {
     // For consistency with what happens in get(), we force offsetExists() to
     // be TRUE for delta 0.
diff --git a/core/modules/comment/src/Entity/Comment.php b/core/modules/comment/src/Entity/Comment.php
index 2fc615f30808dd768535dc48829adf51d254dafc..43123b7a17ff697b5a34a5d3fc85938aa4f586f3 100644
--- a/core/modules/comment/src/Entity/Comment.php
+++ b/core/modules/comment/src/Entity/Comment.php
@@ -193,7 +193,7 @@ public static function postDelete(EntityStorageInterface $storage, array $entiti
     $comments = $comment_storage->loadMultiple($child_cids);
     $comment_storage->delete($comments);
 
-    foreach ($entities as $id => $entity) {
+    foreach ($entities as $entity) {
       \Drupal::service('comment.statistics')->update($entity);
     }
   }
diff --git a/core/modules/content_moderation/src/Permissions.php b/core/modules/content_moderation/src/Permissions.php
index 68639faf306e05899d5982125eabdbef2b0a1fdf..faba77fe60766d5ec80bc35b3e204e6ea239a1c9 100644
--- a/core/modules/content_moderation/src/Permissions.php
+++ b/core/modules/content_moderation/src/Permissions.php
@@ -24,7 +24,7 @@ class Permissions {
   public function transitionPermissions() {
     $permissions = [];
     /** @var \Drupal\workflows\WorkflowInterface $workflow */
-    foreach (Workflow::loadMultipleByType('content_moderation') as $id => $workflow) {
+    foreach (Workflow::loadMultipleByType('content_moderation') as $workflow) {
       foreach ($workflow->getTypePlugin()->getTransitions() as $transition) {
         $permissions['use ' . $workflow->id() . ' transition ' . $transition->id()] = [
           'title' => $this->t('%workflow workflow: Use %transition transition.', [
diff --git a/core/modules/content_moderation/src/ViewsData.php b/core/modules/content_moderation/src/ViewsData.php
index 49ace2054f203a47c1b72769a681c0298736843d..39b69f8ce211bcdeaf9627a7d427b6dbe9b20d92 100644
--- a/core/modules/content_moderation/src/ViewsData.php
+++ b/core/modules/content_moderation/src/ViewsData.php
@@ -55,7 +55,7 @@ public function getViewsData() {
       return $this->moderationInformation->isModeratedEntityType($type);
     });
 
-    foreach ($entity_types_with_moderation as $entity_type_id => $entity_type) {
+    foreach ($entity_types_with_moderation as $entity_type) {
       $table = $entity_type->getDataTable() ?: $entity_type->getBaseTable();
 
       $data[$table]['moderation_state'] = [
diff --git a/core/modules/editor/editor.module b/core/modules/editor/editor.module
index da32ff01cba09d26b393beebef0361ea9621bc33..726b3ab456a889857989676c006b62752acd4e8d 100644
--- a/core/modules/editor/editor.module
+++ b/core/modules/editor/editor.module
@@ -369,7 +369,7 @@ function editor_entity_insert(EntityInterface $entity) {
     return;
   }
   $referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
-  foreach ($referenced_files_by_field as $field => $uuids) {
+  foreach ($referenced_files_by_field as $uuids) {
     _editor_record_file_usage($uuids, $entity);
   }
 }
@@ -387,7 +387,7 @@ function editor_entity_update(EntityInterface $entity) {
   // deletion of previous file usages are necessary.
   if (!empty($entity->original) && $entity->getRevisionId() != $entity->original->getRevisionId()) {
     $referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
-    foreach ($referenced_files_by_field as $field => $uuids) {
+    foreach ($referenced_files_by_field as $uuids) {
       _editor_record_file_usage($uuids, $entity);
     }
   }
@@ -427,7 +427,7 @@ function editor_entity_delete(EntityInterface $entity) {
     return;
   }
   $referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
-  foreach ($referenced_files_by_field as $field => $uuids) {
+  foreach ($referenced_files_by_field as $uuids) {
     _editor_delete_file_usage($uuids, $entity, 0);
   }
 }
@@ -441,7 +441,7 @@ function editor_entity_revision_delete(EntityInterface $entity) {
     return;
   }
   $referenced_files_by_field = _editor_get_file_uuids_by_field($entity);
-  foreach ($referenced_files_by_field as $field => $uuids) {
+  foreach ($referenced_files_by_field as $uuids) {
     _editor_delete_file_usage($uuids, $entity, 1);
   }
 }
diff --git a/core/modules/field/field.purge.inc b/core/modules/field/field.purge.inc
index 27c22a461d38292d8ddd76df23fe6b1ace4f097a..8398f434c889258498d195e1f99cf5b613cd8903 100644
--- a/core/modules/field/field.purge.inc
+++ b/core/modules/field/field.purge.inc
@@ -77,7 +77,6 @@ function field_purge_batch($batch_size, $field_storage_unique_id = NULL) {
 
   $fields = $deleted_fields_repository->getFieldDefinitions($field_storage_unique_id);
 
-  $info = \Drupal::entityTypeManager()->getDefinitions();
   foreach ($fields as $field) {
     $entity_type = $field->getTargetEntityTypeId();
 
diff --git a/core/modules/field_ui/src/Element/FieldUiTable.php b/core/modules/field_ui/src/Element/FieldUiTable.php
index f921398d04e07cb087b786b339d6c3a6d1853cb9..2d234bbc7fb703fb4d8792517dd6b7a1bf03259b 100644
--- a/core/modules/field_ui/src/Element/FieldUiTable.php
+++ b/core/modules/field_ui/src/Element/FieldUiTable.php
@@ -70,6 +70,7 @@ public static function tablePreRender($elements) {
           $region_name = call_user_func_array($row['#region_callback'], [&$row]);
 
           // Add the element in the tree.
+          // phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
           $target = &$trees[$region_name][''];
           foreach ($parents[$name] as $key) {
             $target = &$target['children'][$key];
diff --git a/core/modules/file/src/FileAccessControlHandler.php b/core/modules/file/src/FileAccessControlHandler.php
index e5c444dc3e9f798957ab80300302bd3c5477ca4f..3e1fb492d69c1520a3532b9632ddfe9cee3e9120 100644
--- a/core/modules/file/src/FileAccessControlHandler.php
+++ b/core/modules/file/src/FileAccessControlHandler.php
@@ -31,7 +31,7 @@ protected function checkAccess(EntityInterface $entity, $operation, AccountInter
       }
       elseif ($references = $this->getFileReferences($entity)) {
         foreach ($references as $field_name => $entity_map) {
-          foreach ($entity_map as $referencing_entity_type => $referencing_entities) {
+          foreach ($entity_map as $referencing_entities) {
             /** @var \Drupal\Core\Entity\EntityInterface $referencing_entity */
             foreach ($referencing_entities as $referencing_entity) {
               $entity_and_field_access = $referencing_entity->access('view', $account, TRUE)->andIf($referencing_entity->$field_name->access('view', $account, TRUE));
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
index 12d055114c763edde7380fbe9ed45507ae058651..5d2a03e0b1b6f1f985725a7f5d15de368752a1cd 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/RSSEnclosureFormatter.php
@@ -24,7 +24,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
     $entity = $items->getEntity();
     // Add the first file as an enclosure to the RSS item. RSS allows only one
     // enclosure per item. See: http://wikipedia.org/wiki/RSS_enclosure
-    foreach ($this->getEntitiesToView($items, $langcode) as $delta => $file) {
+    foreach ($this->getEntitiesToView($items, $langcode) as $file) {
       /** @var \Drupal\file\FileInterface $file */
       $entity->rss_elements[] = [
         'key' => 'enclosure',
diff --git a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
index 5bb3d94883972a9e608d933a5fa4626fda25f46f..e6a8db603877425b4a3da635f591809f2c99d070 100644
--- a/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
+++ b/core/modules/file/src/Plugin/Field/FieldFormatter/TableFormatter.php
@@ -26,7 +26,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
     if ($files = $this->getEntitiesToView($items, $langcode)) {
       $header = [t('Attachment'), t('Size')];
       $rows = [];
-      foreach ($files as $delta => $file) {
+      foreach ($files as $file) {
         $item = $file->_referringItem;
         $rows[] = [
           [
diff --git a/core/modules/filter/src/Plugin/Filter/FilterHtml.php b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
index a40e048d41fbbc1b768be44a9c01819616f5d955..1db9d1c761229c8937a151ccf6827aad3deabcf1 100644
--- a/core/modules/filter/src/Plugin/Filter/FilterHtml.php
+++ b/core/modules/filter/src/Plugin/Filter/FilterHtml.php
@@ -285,7 +285,7 @@ public function getHTMLRestrictions() {
           // allowed attribute values with a wildcard. A wildcard by itself
           // would mean allowing all possible attribute values. But in that
           // case, one would not specify an attribute value at all.
-          $allowed_attribute_values = array_filter($allowed_attribute_values, function ($value) use ($star_protector) {
+          $allowed_attribute_values = array_filter($allowed_attribute_values, function ($value) {
             return $value !== '*';
           });
 
diff --git a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php
index d9938339aaf730517bd6fcee3386147064c7ce2d..cdaa34ac522c7dd0e21232ae0e8b755a7aa28d95 100644
--- a/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php
+++ b/core/modules/jsonapi/src/Normalizer/ResourceIdentifierNormalizer.php
@@ -77,9 +77,6 @@ public function denormalize($data, $class, $format = NULL, array $context = [])
     }
     /** @var \Drupal\field\Entity\FieldConfig $field_definition */
     $field_definition = $field_definitions[$context['related']];
-    // This is typically 'target_id'.
-    $item_definition = $field_definition->getItemDefinition();
-    $property_key = $item_definition->getMainPropertyName();
     $target_resource_types = $resource_type->getRelatableResourceTypesByField($resource_type->getPublicName($context['related']));
     $target_resource_type_names = array_map(function (ResourceType $resource_type) {
       return $resource_type->getTypeName();
@@ -87,7 +84,7 @@ public function denormalize($data, $class, $format = NULL, array $context = [])
 
     $is_multiple = $field_definition->getFieldStorageDefinition()->isMultiple();
     $data = $this->massageRelationshipInput($data, $is_multiple);
-    $resource_identifiers = array_map(function ($value) use ($property_key, $target_resource_type_names) {
+    $resource_identifiers = array_map(function ($value) use ($target_resource_type_names) {
       // Make sure that the provided type is compatible with the targeted
       // resource.
       if (!in_array($value['type'], $target_resource_type_names)) {
diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
index 70e86f69991359deb6c086cc1a12df7a3711037e..d543fe1619557edbaf532c41c700706515218e93 100644
--- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
+++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplay.php
@@ -360,9 +360,9 @@ public function label() {
   public function calculateDependencies() {
     parent::calculateDependencies();
 
-    foreach ($this->getSections() as $delta => $section) {
+    foreach ($this->getSections() as $section) {
       $this->calculatePluginDependencies($section->getLayout());
-      foreach ($section->getComponents() as $uuid => $component) {
+      foreach ($section->getComponents() as $component) {
         $this->calculatePluginDependencies($component->getPlugin());
       }
     }
diff --git a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplayStorage.php b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplayStorage.php
index d701213f9eecee0e56e139fb13b3caf41ceca47f..a221f51fc6346edf7aeb41138c66951f8da3ebea 100644
--- a/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplayStorage.php
+++ b/core/modules/layout_builder/src/Entity/LayoutBuilderEntityViewDisplayStorage.php
@@ -32,7 +32,7 @@ protected function mapToStorageRecord(EntityInterface $entity) {
    * {@inheritdoc}
    */
   protected function mapFromStorageRecords(array $records) {
-    foreach ($records as $id => &$record) {
+    foreach ($records as &$record) {
       if (!empty($record['third_party_settings']['layout_builder']['sections'])) {
         $sections = &$record['third_party_settings']['layout_builder']['sections'];
         $sections = array_map([Section::class, 'fromArray'], $sections);
diff --git a/core/modules/layout_builder/src/Field/LayoutSectionItemList.php b/core/modules/layout_builder/src/Field/LayoutSectionItemList.php
index 9870bc41b39ef8f5c1573f5e2a906fcde44e1c9b..111acd0f1cc4e9ba22ca655331eb6b84f997cd23 100644
--- a/core/modules/layout_builder/src/Field/LayoutSectionItemList.php
+++ b/core/modules/layout_builder/src/Field/LayoutSectionItemList.php
@@ -73,7 +73,7 @@ public function preSave() {
     parent::preSave();
     // Loop through each section and reconstruct it to ensure that all default
     // values are present.
-    foreach ($this->list as $delta => $item) {
+    foreach ($this->list as $item) {
       $item->section = Section::fromArray($item->section->toArray());
     }
   }
diff --git a/core/modules/locale/src/Form/TranslationStatusForm.php b/core/modules/locale/src/Form/TranslationStatusForm.php
index e354153dfd758d3a042ae60650a1649fbfef5df2..4fd147ca22f2185bc21025f41a2b952f88969e35 100644
--- a/core/modules/locale/src/Form/TranslationStatusForm.php
+++ b/core/modules/locale/src/Form/TranslationStatusForm.php
@@ -195,7 +195,7 @@ protected function prepareUpdateData(array $status) {
     $this->moduleHandler->loadInclude('locale', 'compare.inc');
     $project_data = locale_translation_build_projects();
 
-    foreach ($status as $project_id => $project) {
+    foreach ($status as $project) {
       foreach ($project as $langcode => $project_info) {
         // No translation file found for this project-language combination.
         if (empty($project_info->type)) {
diff --git a/core/modules/media/src/Controller/OEmbedIframeController.php b/core/modules/media/src/Controller/OEmbedIframeController.php
index a19d2b65e9be39004b0cb7890879b08d27d654b4..5e7b12ff3766092d54e0abe0a19f3e76ef2a4a15 100644
--- a/core/modules/media/src/Controller/OEmbedIframeController.php
+++ b/core/modules/media/src/Controller/OEmbedIframeController.php
@@ -171,7 +171,7 @@ public function render(Request $request) {
         '#placeholder_token' => $placeholder_token,
       ];
       $context = new RenderContext();
-      $content = $this->renderer->executeInRenderContext($context, function () use ($resource, $element) {
+      $content = $this->renderer->executeInRenderContext($context, function () use ($element) {
         return $this->renderer->render($element);
       });
       $response
diff --git a/core/modules/media/src/OEmbed/UrlResolver.php b/core/modules/media/src/OEmbed/UrlResolver.php
index eb2e6cffbb3b4100c8344a61dc0259ed2bd9006c..055729ab3cb2727df02e2d681ad10495881c6079 100644
--- a/core/modules/media/src/OEmbed/UrlResolver.php
+++ b/core/modules/media/src/OEmbed/UrlResolver.php
@@ -130,7 +130,7 @@ protected function findUrl(\DOMXPath $xpath, $format) {
   public function getProviderByUrl($url) {
     // Check the URL against every scheme of every endpoint of every provider
     // until we find a match.
-    foreach ($this->providers->getAll() as $provider_name => $provider_info) {
+    foreach ($this->providers->getAll() as $provider_info) {
       foreach ($provider_info->getEndpoints() as $endpoint) {
         if ($endpoint->matchUrl($url)) {
           return $provider_info;
diff --git a/core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php b/core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php
index d5f9d2febe83adaa30a96f554b99f3441b00a2be..acb83662fba66940f7fc9db8cea5ae403ff9709d 100644
--- a/core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php
+++ b/core/modules/migrate/src/Plugin/migrate/process/ArrayBuild.php
@@ -82,7 +82,7 @@ class ArrayBuild extends ProcessPluginBase {
   public function transform($value, MigrateExecutableInterface $migrate_executable, Row $row, $destination_property) {
     $new_value = [];
 
-    foreach ((array) $value as $old_key => $old_value) {
+    foreach ((array) $value as $old_value) {
       // Checks that $old_value is an array.
       if (!is_array($old_value)) {
         throw new MigrateException("The input should be an array of arrays");
diff --git a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
index feca681f59f444fa191bafcbb645472399bc5df8..158b3a8914d1606672bc5b8f1a6a99bad8c9f437 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/EmbeddedDataSource.php
@@ -113,6 +113,7 @@ public function getIds() {
   /**
    * {@inheritdoc}
    */
+  #[\ReturnTypeWillChange]
   public function count($refresh = FALSE) {
     // We do not want this source plugin to have a cacheable count.
     // @see \Drupal\migrate_cache_counts_test\Plugin\migrate\source\CacheableEmbeddedDataSource
diff --git a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
index 7e4a009d7c22b7915fd7f198bc5d06fecb0699b8..4a1c35ebc42c9b425b13d2193e30fcf7dd4d52ed 100644
--- a/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
+++ b/core/modules/migrate/src/Plugin/migrate/source/SqlBase.php
@@ -266,9 +266,6 @@ protected function initializeIterator() {
     if ($this->batch == 0) {
       $this->prepareQuery();
 
-      // Get the key values, for potential use in joining to the map table.
-      $keys = [];
-
       // The rules for determining what conditions to add to the query are as
       // follows (applying first applicable rule):
       // 1. If the map is joinable, join it. We will want to accept all rows
diff --git a/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php b/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php
index 510e776000a8284e19cb9c84a0f002b321625fe5..47dd1b733092537013ff5490ab67ee8926d0fc91 100644
--- a/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php
+++ b/core/modules/migrate/tests/modules/migrate_cache_counts_test/src/Plugin/migrate/source/CacheableEmbeddedDataSource.php
@@ -18,6 +18,7 @@ class CacheableEmbeddedDataSource extends EmbeddedDataSource {
   /**
    * {@inheritdoc}
    */
+  #[\ReturnTypeWillChange]
   public function count($refresh = FALSE) {
     return SourcePluginBase::count($refresh);
   }
diff --git a/core/modules/migrate_drupal/src/MigrationState.php b/core/modules/migrate_drupal/src/MigrationState.php
index b49ff32dcd5a914822f48ce46aaa83b9bd5d3378..ca368684919a699514e11a964c11e29f7e6a0465 100644
--- a/core/modules/migrate_drupal/src/MigrationState.php
+++ b/core/modules/migrate_drupal/src/MigrationState.php
@@ -382,7 +382,7 @@ protected function buildDeclaredStateBySource($version) {
     $state_by_source = [];
     $dest_by_source = [];
     $states = [static::FINISHED, static::NOT_FINISHED];
-    foreach ($migration_states as $module => $info) {
+    foreach ($migration_states as $info) {
       foreach ($states as $state) {
         if (isset($info[$state][$version])) {
           foreach ($info[$state][$version] as $source => $destination) {
diff --git a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
index 28f20a7bcb4f15a2d6b371e4b44f60b5dc8f6e50..798b1eda6b45c4f058e9e44e27370d394718029a 100644
--- a/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
+++ b/core/modules/migrate_drupal/src/Plugin/migrate/source/ContentEntity.php
@@ -242,6 +242,7 @@ public function query() {
   /**
    * {@inheritdoc}
    */
+  #[\ReturnTypeWillChange]
   public function count($refresh = FALSE) {
     // If no translations are included, then a simple query is possible.
     if (!$this->configuration['include_translations']) {
diff --git a/core/modules/node/src/NodeAccessControlHandler.php b/core/modules/node/src/NodeAccessControlHandler.php
index 25b38671318875c633af29c761f39a1f81fc8d8f..a3a5e9333ebc3ed3b931380f6b5f1b3417fc42b4 100644
--- a/core/modules/node/src/NodeAccessControlHandler.php
+++ b/core/modules/node/src/NodeAccessControlHandler.php
@@ -141,7 +141,7 @@ protected function checkAccess(EntityInterface $node, $operation, AccountInterfa
       return AccessResult::allowed()->cachePerPermissions()->cachePerUser()->addCacheableDependency($node);
     }
 
-    [$revision_permission_operation, $entity_operation] = static::REVISION_OPERATION_MAP[$operation] ?? [
+    [$revision_permission_operation] = static::REVISION_OPERATION_MAP[$operation] ?? [
       NULL,
       NULL,
     ];
diff --git a/core/modules/rdf/rdf.module b/core/modules/rdf/rdf.module
index 69b5f724ebddde0f785a6ce3742ef513dd6b79e1..39209dd0222dbde4fb5b1b3869c8902e090cef43 100644
--- a/core/modules/rdf/rdf.module
+++ b/core/modules/rdf/rdf.module
@@ -358,9 +358,7 @@ function rdf_preprocess_node(&$variables) {
       $fields = array_keys(\Drupal::service('comment.manager')->getFields('node'));
       $definitions = array_keys($variables['node']->getFieldDefinitions());
       $valid_fields = array_intersect($fields, $definitions);
-      $count = 0;
       foreach ($valid_fields as $field_name) {
-        $count += $variables['node']->get($field_name)->comment_count;
         // Adds RDFa markup for the comment count near the node title as
         // metadata.
         $comment_count_attributes = rdf_rdfa_attributes($comment_count_mapping, $variables['node']->get($field_name)->comment_count);
diff --git a/core/modules/rest/src/Plugin/rest/resource/EntityResourceAccessTrait.php b/core/modules/rest/src/Plugin/rest/resource/EntityResourceAccessTrait.php
index 7bf8e824e15987aefee3ae8226549904405abdd6..32ea8391b48cd60e2f860f5e86d5c4db1a68ef33 100644
--- a/core/modules/rest/src/Plugin/rest/resource/EntityResourceAccessTrait.php
+++ b/core/modules/rest/src/Plugin/rest/resource/EntityResourceAccessTrait.php
@@ -25,7 +25,7 @@ protected function checkEditFieldAccess(EntityInterface $entity) {
     // Only check 'edit' permissions for fields that were actually submitted by
     // the user. Field access makes no difference between 'create' and 'update',
     // so the 'edit' operation is used here.
-    foreach ($entity->_restSubmittedFields as $key => $field_name) {
+    foreach ($entity->_restSubmittedFields as $field_name) {
       if (!$entity->get($field_name)->access('edit')) {
         throw new AccessDeniedHttpException("Access denied on creating field '$field_name'.");
       }
diff --git a/core/modules/system/system.post_update.php b/core/modules/system/system.post_update.php
index a7230ecd29391d03e3c9b058f14420b8efdfeadb..e2e467ef97a29e4598a06e244ebb7a817a4182aa 100644
--- a/core/modules/system/system.post_update.php
+++ b/core/modules/system/system.post_update.php
@@ -100,7 +100,7 @@ function system_post_update_entity_revision_metadata_bc_cleanup() {
   });
 
   // Remove the '$requiredRevisionMetadataKeys' property for these entity types.
-  foreach ($last_installed_definitions as $entity_type_id => $entity_type) {
+  foreach ($last_installed_definitions as $entity_type) {
     $closure = function (ContentEntityTypeInterface $entity_type) {
       return get_object_vars($entity_type);
     };
diff --git a/core/modules/taxonomy/src/Form/OverviewTerms.php b/core/modules/taxonomy/src/Form/OverviewTerms.php
index 0b918bf7314ed4687f38a27637c4387b5cd447aa..ebc9e5933c016883d9cb871882469aa69b49f1da 100644
--- a/core/modules/taxonomy/src/Form/OverviewTerms.php
+++ b/core/modules/taxonomy/src/Form/OverviewTerms.php
@@ -161,6 +161,7 @@ public function buildForm(array $form, FormStateInterface $form_state, Vocabular
     $term_deltas = [];
     $tree = $this->storageController->loadTree($taxonomy_vocabulary->id(), 0, NULL, TRUE);
     $tree_index = 0;
+    $complete_tree = NULL;
     do {
       // In case this tree is completely empty.
       if (empty($tree[$tree_index])) {
diff --git a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
index 1ccee9737a4396af164fbabbe83f6d60e6306f60..295852c3fc117189d51aa6535e60072f1724a168 100644
--- a/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
+++ b/core/modules/taxonomy/src/Plugin/EntityReferenceSelection/TermSelection.php
@@ -89,7 +89,7 @@ public function countReferenceableEntities($match = NULL, $match_operator = 'CON
 
     $total = 0;
     $referenceable_entities = $this->getReferenceableEntities($match, $match_operator, 0);
-    foreach ($referenceable_entities as $bundle => $entities) {
+    foreach ($referenceable_entities as $entities) {
       $total += count($entities);
     }
     return $total;
diff --git a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
index 8d9afeefd3f1dd9df0b9cd4e32efa8fd2f9bc208..81d1f4b475fe30ff7b32ef9ea6555712338dfebf 100644
--- a/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
+++ b/core/modules/taxonomy/src/Plugin/Field/FieldFormatter/EntityReferenceTaxonomyTermRssFormatter.php
@@ -28,7 +28,7 @@ public function viewElements(FieldItemListInterface $items, $langcode) {
     $parent_entity = $items->getEntity();
     $elements = [];
 
-    foreach ($this->getEntitiesToView($items, $langcode) as $delta => $entity) {
+    foreach ($this->getEntitiesToView($items, $langcode) as $entity) {
       $parent_entity->rss_elements[] = [
         'key' => 'category',
         'value' => $entity->label(),
diff --git a/core/modules/toolbar/src/Controller/ToolbarController.php b/core/modules/toolbar/src/Controller/ToolbarController.php
index 75986f901b0f74a0e83d1c390b71aa092fc80f72..e887c4677976ddadb14a869f94d1eed3969174bf 100644
--- a/core/modules/toolbar/src/Controller/ToolbarController.php
+++ b/core/modules/toolbar/src/Controller/ToolbarController.php
@@ -21,7 +21,7 @@ class ToolbarController extends ControllerBase implements TrustedCallbackInterfa
    * @return \Drupal\Core\Ajax\AjaxResponse
    */
   public function subtreesAjax() {
-    [$subtrees, $cacheability] = toolbar_get_rendered_subtrees();
+    [$subtrees] = toolbar_get_rendered_subtrees();
     $response = new AjaxResponse();
     $response->addCommand(new SetSubtreesCommand($subtrees));
 
diff --git a/core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php b/core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
index 7087dc4e80b8cddf90ed64aace8a1e3edc148f0e..4f78e193f020ebe3231b3872126ca973d6705840 100644
--- a/core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
+++ b/core/modules/user/src/Plugin/migrate/process/d6/ProfileFieldOptionTranslation.php
@@ -29,7 +29,7 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
       $list = array_map('trim', $list);
       $list = array_filter($list, 'strlen');
       if ($field_type === 'list_string') {
-        foreach ($list as $key => $value) {
+        foreach ($list as $value) {
           $allowed_values[] = ['label' => $value];
         }
       }
diff --git a/core/modules/user/src/RegisterForm.php b/core/modules/user/src/RegisterForm.php
index f1efe4a79caa6df6376b813dd24f12b87b151126..0a4da2dcf1eee34692a12a3cdfa4d0f2d5aff335 100644
--- a/core/modules/user/src/RegisterForm.php
+++ b/core/modules/user/src/RegisterForm.php
@@ -15,7 +15,6 @@ class RegisterForm extends AccountForm {
    * {@inheritdoc}
    */
   public function form(array $form, FormStateInterface $form_state) {
-    $user = $this->currentUser();
     /** @var \Drupal\user\UserInterface $account */
     $account = $this->entity;
 
diff --git a/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php b/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
index 52d112d840b504fde200afaaf3759983ef41eccc..fbd9f4855bea9e68b2a12241c16aec3b20163507 100644
--- a/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
+++ b/core/modules/views/src/EventSubscriber/ViewsEntitySchemaSubscriber.php
@@ -246,7 +246,7 @@ public function onEntityTypeDelete(EntityTypeInterface $entity_type) {
 
     $all_views = $this->entityTypeManager->getStorage('view')->loadMultiple(NULL);
     /** @var \Drupal\views\Entity\View $view */
-    foreach ($all_views as $id => $view) {
+    foreach ($all_views as $view) {
 
       // First check just the base table.
       if (in_array($view->get('base_table'), $tables)) {
diff --git a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
index 4fe6c872c40665516f2cd87cf865bccba41e5ab8..09205f227de71b9a94105445e63e44dee88fefe8 100644
--- a/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
+++ b/core/modules/views/src/Plugin/views/cache/CachePluginBase.php
@@ -243,7 +243,7 @@ public function getCacheTags() {
 
     if (!empty($entity_information)) {
       // Add the list cache tags for each entity type used by this view.
-      foreach ($entity_information as $table => $metadata) {
+      foreach ($entity_information as $metadata) {
         $tags = Cache::mergeTags($tags, \Drupal::entityTypeManager()->getDefinition($metadata['entity_type'])->getListCacheTags());
       }
     }
diff --git a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
index 4a9f2fbbdd85af007f4b7a5db6e2f8b588f77bb9..338c5fe72d75cc49f75d037f445ad4c8a992821a 100644
--- a/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/DisplayPluginBase.php
@@ -2520,7 +2520,7 @@ public function validate() {
     // Check for missing relationships.
     $relationships = array_keys($this->getHandlers('relationship'));
     foreach (ViewExecutable::getHandlerTypes() as $type => $handler_type_info) {
-      foreach ($this->getHandlers($type) as $handler_id => $handler) {
+      foreach ($this->getHandlers($type) as $handler) {
         if (!empty($handler->options['relationship']) && $handler->options['relationship'] != 'none' && !in_array($handler->options['relationship'], $relationships)) {
           $errors[] = $this->t('The %handler_type %handler uses a relationship that has been removed.', ['%handler_type' => $handler_type_info['lstitle'], '%handler' => $handler->adminLabel()]);
         }
diff --git a/core/modules/views/src/Plugin/views/display/PathPluginBase.php b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
index ca3e6b7dfd67ed1881fba7ac0252ec27ee6aad04..b8eb284a3b567923100e7dfc86bc6f1fcb8211b9 100644
--- a/core/modules/views/src/Plugin/views/display/PathPluginBase.php
+++ b/core/modules/views/src/Plugin/views/display/PathPluginBase.php
@@ -338,13 +338,10 @@ public function getMenuLinks() {
 
     // Replace % with %views_arg for menu autoloading and add to the
     // page arguments so the argument actually comes through.
-    foreach ($bits as $pos => $bit) {
-      if ($bit == '%') {
-        // If a view requires any arguments we cannot create a static menu link.
-        return [];
-      }
+    if (in_array('%', $bits, TRUE)) {
+      // If a view requires any arguments we cannot create a static menu link.
+      return [];
     }
-
     $path = implode('/', $bits);
     $view_id = $this->view->storage->id();
     $display_id = $this->display['id'];
diff --git a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
index ff5261cadb796f4f5fef86c386d7ff6e2773f75b..0892bce15d69a7dcaadb6cc42ac9b5dc0cc1c035 100644
--- a/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
+++ b/core/modules/views/src/Plugin/views/exposed_form/ExposedFormPluginBase.php
@@ -158,7 +158,7 @@ public function query() {
       // Make sure the original order of sorts is preserved
       // (e.g. a sticky sort is often first)
       $view->query->orderby = [];
-      foreach ($view->sort as $key => $sort) {
+      foreach ($view->sort as $sort) {
         if (!$sort->isExposed()) {
           $sort->query();
         }
diff --git a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
index 13585fd745a470218aa3de43ff4675d7996729c7..27277a5e3e92a676455e0da2307e01dffd355692 100644
--- a/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
+++ b/core/modules/views/src/Plugin/views/query/QueryPluginBase.php
@@ -119,7 +119,7 @@ public function summaryTitle() {
   public function calculateDependencies() {
     $dependencies = [];
 
-    foreach ($this->getEntityTableInfo() as $entity_type => $info) {
+    foreach ($this->getEntityTableInfo() as $info) {
       if (!empty($info['provider'])) {
         $dependencies['module'][] = $info['provider'];
       }
diff --git a/core/modules/views/src/Plugin/views/query/Sql.php b/core/modules/views/src/Plugin/views/query/Sql.php
index 0a639958893bb1a10c832b3854948fc040b2ecb8..978d5fe116cab6db0dfd4e40420066196c5321a4 100644
--- a/core/modules/views/src/Plugin/views/query/Sql.php
+++ b/core/modules/views/src/Plugin/views/query/Sql.php
@@ -1357,7 +1357,7 @@ public function query($get_count = FALSE) {
         ];
       }
 
-      foreach ($entity_information as $entity_type_id => $info) {
+      foreach ($entity_information as $info) {
         $entity_type = \Drupal::entityTypeManager()->getDefinition($info['entity_type']);
         $base_field = !$info['revision'] ? $entity_type->getKey('id') : $entity_type->getKey('revision');
         $this->addField($info['alias'], $base_field, '', $params);
diff --git a/core/modules/views/src/Plugin/views/style/Table.php b/core/modules/views/src/Plugin/views/style/Table.php
index 11552188ddaa93f32366922ebfec8039fc103c76..fb75b0dedd792083affa30baf7878ca2c27cfa6d 100644
--- a/core/modules/views/src/Plugin/views/style/Table.php
+++ b/core/modules/views/src/Plugin/views/style/Table.php
@@ -433,7 +433,7 @@ public function getCacheMaxAge() {
   public function getCacheContexts() {
     $contexts = [];
 
-    foreach ($this->options['info'] as $field_id => $info) {
+    foreach ($this->options['info'] as $info) {
       if (!empty($info['sortable'])) {
         // The rendered link needs to play well with any other query parameter
         // used on the page, like pager and exposed filter.
diff --git a/core/modules/views_ui/src/Controller/ViewsUIController.php b/core/modules/views_ui/src/Controller/ViewsUIController.php
index c5ccdf23b32dc1ede22c2850c0544e278ba9446b..b81bf43175548d9894ce2cfd6b2d61db00af1dac 100644
--- a/core/modules/views_ui/src/Controller/ViewsUIController.php
+++ b/core/modules/views_ui/src/Controller/ViewsUIController.php
@@ -121,7 +121,7 @@ public function reportPlugins() {
     foreach ($rows as &$row) {
       $views = [];
       // Link each view name to the view itself.
-      foreach ($row['views'] as $row_name => $view) {
+      foreach ($row['views'] as $view) {
         $views[] = Link::fromTextAndUrl($view, new Url('entity.view.edit_form', ['view' => $view]))->toString();
       }
       unset($row['views']);
diff --git a/core/modules/workspaces/src/EntityTypeInfo.php b/core/modules/workspaces/src/EntityTypeInfo.php
index 5052d30899a9dfd251ff98f11713ab9e29979433..bf9d82fedfad03b08609eacfe7781fc1ad083bd2 100644
--- a/core/modules/workspaces/src/EntityTypeInfo.php
+++ b/core/modules/workspaces/src/EntityTypeInfo.php
@@ -83,7 +83,7 @@ public function entityTypeBuild(array &$entity_types) {
    * @see hook_entity_type_alter()
    */
   public function entityTypeAlter(array &$entity_types) {
-    foreach ($entity_types as $entity_type_id => $entity_type) {
+    foreach ($entity_types as $entity_type) {
       // Non-default workspaces display the active revision on the canonical
       // route of an entity, so the latest version route is no longer needed.
       $link_templates = $entity_type->get('links');
diff --git a/core/modules/workspaces/src/WorkspacesServiceProvider.php b/core/modules/workspaces/src/WorkspacesServiceProvider.php
index adc08bbce3ae1dd9ed4f0f4531538638263b4a38..e9c869d977c72011ece38941f4f2d3c668f429ef 100644
--- a/core/modules/workspaces/src/WorkspacesServiceProvider.php
+++ b/core/modules/workspaces/src/WorkspacesServiceProvider.php
@@ -34,7 +34,7 @@ public function alter(ContainerBuilder $container) {
     // Ensure that there's no active workspace while running database updates by
     // removing the relevant tag from all workspace negotiator services.
     if ($container->get('kernel') instanceof UpdateKernel) {
-      foreach ($container->getDefinitions() as $id => $definition) {
+      foreach ($container->getDefinitions() as $definition) {
         if ($definition->hasTag('workspace_negotiator')) {
           $definition->clearTag('workspace_negotiator');
         }
diff --git a/core/phpcs.xml.dist b/core/phpcs.xml.dist
index de9eefb69260928680f668a491ba71f988604e40..b0782ff6bff84e2071ec07f185608a9acc5c686f 100644
--- a/core/phpcs.xml.dist
+++ b/core/phpcs.xml.dist
@@ -145,6 +145,24 @@
   <rule ref="DrupalPractice.Commenting.ExpectedException"/>
   <rule ref="DrupalPractice.General.ExceptionT"/>
   <rule ref="DrupalPractice.InfoFiles.NamespacedDependency"/>
+  <rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis">
+    <!-- @todo exclude tests -->
+    <exclude-pattern>*/tests/*</exclude-pattern>
+    <!-- Do not run this sniff on API files or transliteration data. -->
+    <exclude-pattern>*.api.php</exclude-pattern>
+    <exclude-pattern>core/lib/Drupal/Component/Transliteration/data/*.php</exclude-pattern>
+    <properties>
+      <property name="allowUnusedFunctionParameters" value="true"/>
+    </properties>
+  </rule>
+  <rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedVariable">
+    <!-- Setting severity to 0 to completely disable an error message in this sniff, without excluding the whole sniff -->
+    <!-- See https://github.com/squizlabs/PHP_CodeSniffer/wiki/Configuration-Options#changing-the-default-severity-levels -->
+    <severity>0</severity>
+  </rule>
+  <rule ref="DrupalPractice.CodeAnalysis.VariableAnalysis.UndefinedUnsetVariable">
+    <severity>0</severity>
+  </rule>
 
   <!-- Generic sniffs -->
   <rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
diff --git a/core/scripts/db-tools.php b/core/scripts/db-tools.php
index dccd69ce218dffa62e051274de84d3753ffc2e77..6efa58dac8002ae438e006e662c21799b60160ca 100644
--- a/core/scripts/db-tools.php
+++ b/core/scripts/db-tools.php
@@ -19,7 +19,7 @@
 $autoloader = require __DIR__ . '/../../autoload.php';
 $request = Request::createFromGlobals();
 Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
-$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
+DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
 
 // Run the database dump command.
 $application = new DbToolsApplication();
diff --git a/core/scripts/dump-database-d8-mysql.php b/core/scripts/dump-database-d8-mysql.php
index bce5d549bc41e3b0f468ff16c10e377162c132f2..1fd14e807afd714c1ae7cfa90ccceeb007bb555b 100644
--- a/core/scripts/dump-database-d8-mysql.php
+++ b/core/scripts/dump-database-d8-mysql.php
@@ -19,7 +19,7 @@
 $autoloader = require __DIR__ . '/../../autoload.php';
 $request = Request::createFromGlobals();
 Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
-$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
+DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
 
 // Run the database dump command.
 $application = new DbDumpApplication();
diff --git a/core/scripts/generate-proxy-class.php b/core/scripts/generate-proxy-class.php
index d277c34d5ee3bbfd3db1c7507f2c81a41d302af5..2664739be4232d161d5eff79505c801e26263bf8 100644
--- a/core/scripts/generate-proxy-class.php
+++ b/core/scripts/generate-proxy-class.php
@@ -20,7 +20,7 @@
 $autoloader = require __DIR__ . '/../../autoload.php';
 $request = Request::createFromGlobals();
 Settings::initialize(dirname(__DIR__, 2), DrupalKernel::findSitePath($request), $autoloader);
-$kernel = DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
+DrupalKernel::createFromRequest($request, $autoloader, 'prod')->boot();
 
 // Run the database dump command.
 $application = new GenerateProxyClassApplication(new ProxyBuilder());
diff --git a/core/tests/Drupal/FunctionalTests/Bootstrap/ErrorContainer.php b/core/tests/Drupal/FunctionalTests/Bootstrap/ErrorContainer.php
index e88cc88c9050453f3260aa59f20bd9f905cfe721..dd36af07ee6693d1d4d63023f51019bdfca0a569 100644
--- a/core/tests/Drupal/FunctionalTests/Bootstrap/ErrorContainer.php
+++ b/core/tests/Drupal/FunctionalTests/Bootstrap/ErrorContainer.php
@@ -17,11 +17,9 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
       // Enforce a recoverable error.
       $callable = function (ErrorContainer $container) {
       };
-      $callable(1);
-    }
-    else {
-      return parent::get($id, $invalidBehavior);
+      return $callable(1);
     }
+    return parent::get($id, $invalidBehavior);
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
index 2ff8083fee46b669543a661bdc22b901a276b517..92c627a8ada02b2d28f3a06d7a8eb27a5faa13b5 100644
--- a/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
+++ b/core/tests/Drupal/Tests/Component/ProxyBuilder/ProxyBuilderTest.php
@@ -436,7 +436,7 @@ public function methodWithParameter($parameter) {
 class TestServiceComplexMethod {
 
   public function complexMethod(string $parameter, callable $function, TestServiceNoMethod $test_service = NULL, array &$elements = []): array {
-
+    return [];
   }
 
 }
@@ -444,7 +444,7 @@ public function complexMethod(string $parameter, callable $function, TestService
 class TestServiceNullableTypehintSelf {
 
   public function typehintSelf(?self $parameter): ?self {
-
+    return NULL;
   }
 
 }
diff --git a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/MimeTypePassTest.php b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/MimeTypePassTest.php
index 121c7d26b39bf105c577cd650dbf977282f4db14..a92b5a1e2c4ad433a7b14bde06a989734b7115bc 100644
--- a/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/MimeTypePassTest.php
+++ b/core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/MimeTypePassTest.php
@@ -51,9 +51,13 @@ public function testProcessLegacy() {
 
 class NewMimeTypeGuesser implements MimeTypeGuesserInterface {
 
-  public function guessMimeType(string $string): string {}
+  public function guessMimeType(string $string): string {
+    return '';
+  }
 
-  public function isGuesserSupported(): bool {}
+  public function isGuesserSupported(): bool {
+    return TRUE;
+  }
 
 }
 
diff --git a/core/themes/bartik/color/color.inc b/core/themes/bartik/color/color.inc
index 67b092f1600f9003bf1310f3ff40b8171cbe9979..d7265944b27c3182e31157199a5b4338f94322cd 100644
--- a/core/themes/bartik/color/color.inc
+++ b/core/themes/bartik/color/color.inc
@@ -5,6 +5,7 @@
  * Lists available colors and color schemes for the Bartik theme.
  */
 
+// phpcs:ignore DrupalPractice.CodeAnalysis.VariableAnalysis.UnusedVariable
 $info = [
   // Available colors and color labels used in theme.
   'fields' => [